c# 添加数据
/// <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();//重新绑 } }
清空回声