protected void formView_ItemCommand(object sender, FormViewCommandEventArgs e) { if (e.CommandName == "InsertJldw") { YC.SQLServerDAL.Jldw jldw = new YC.SQLServerDAL.Jldw(); // 计量单位名称 TextBox tbName = formView.FindControl("tbName") as TextBox; jldw.Name = tbName.Text; tbName.Text = ""; // 排序号 TextBox tbOrderIndex = formView.FindControl("tbOrderIndex") as TextBox; double orderIndex = 0; Double.TryParse(tbOrderIndex.Text, out orderIndex); jldw.OrderIndex = orderIndex; tbOrderIndex.Text = ""; YC.SQLServerDAL.Jldw newJldw = bll_Jldw.NewJldw(jldw); if (newJldw != null && JldwCreated != null) { JldwInsertedEventArgs args = new JldwInsertedEventArgs(newJldw); JldwCreated(this, args); } } if (e.CommandName == "Cancel") { if (this.Canceled != null) { Canceled(this, null); } } }
/// <summary> /// 创建新计量单位(此计量单位为安装设备的所在单位) /// </summary> /// <returns></returns> public YC.SQLServerDAL.Jldw NewJldw(YC.SQLServerDAL.Jldw jldw) { if (jldw != null) { if (!ExistJldw(jldw.Name)) { jldw.JLDWID = Guid.NewGuid(); dbContext.Jldw.InsertOnSubmit(jldw); dbContext.SubmitChanges(); } } return(jldw); }
/// <summary> /// 在数据库中新增计量单位对象。 /// </summary> /// <param name="name">计量单位名称。</param> /// <returns></returns> public YC.SQLServerDAL.Jldw CreateJldw(string name) { var jldw = new YC.SQLServerDAL.Jldw(); jldw.JLDWID = Guid.NewGuid(); jldw.Name = name; jldw.OrderIndex = 0; if (!ExistJldw(jldw.Name)) { dbContext.Jldw.InsertOnSubmit(jldw); dbContext.SubmitChanges(); } return(jldw); }
public JldwInsertedEventArgs(YC.SQLServerDAL.Jldw jldw) { this._jldw = jldw; }
public void UpdateJldw(YC.SQLServerDAL.Jldw jldw) { dbContext.SubmitChanges(); }