码迷,mamicode.com
首页 > Windows程序 > 详细

c# 添加数据

时间:2014-11-09 20:40:00      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   os   sp   数据   div   on   

   /// <summary>
        /// 新增一条省份记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddProvince(m_province model)
        {
            using (var _DataEntities = new ntasystemEntities())
            {
                if (model != null)
                {
                    _DataEntities.m_province.AddObject(model);
                }
                return _DataEntities.SaveChanges();

            }
        }
 public void AddProvince()
        {
            
            if (CheckDateProvince())
            {
                m_province entity = new m_province();
                int num = Convert.ToInt32(wcf.GetProvinceMaxNum());
                int Maxnum = num + 1;
                entity.No = Maxnum.ToString();
                entity.Name_en = this.txtnameen.Text.Trim().ToString();
                entity.Name_cn = this.txtnamecn.Text.Trim().ToString();
                entity.Country_no = this.cmbCountryNo.SelectedValue.ToString();
                entity.Province_ab = this.txtProvince_ab.Text.Trim().ToString();
                entity.mader = wcf.GetUserByNo(Helper.GlobalVariables.Gs_Current_User.No).Name_cn;//当前登陆者
                entity.made_dist = "A";//标示
                entity.made_time = DateTime.Now;
                if (wcf.AddProvince(entity) > 0)
                {
                    MessageBox.Show("新增成功!");
                    BindDateGridView();//重新绑
                }
            }
           

 

c# 添加数据

标签:style   blog   color   ar   os   sp   数据   div   on   

原文地址:http://www.cnblogs.com/Echo529/p/4085781.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!