public static string InsertDepartment(LDepartment pitems) { int i = 0; Query _QueryRS = LDepartment.CreateQuery(); try { if (!LDepartment.FetchByParameter(LDepartment.Columns.Id, Comparison.Equals, pitems.Id).Read()) { pitems.IsNew = true; pitems.Save(i); return(_QueryRS.GetMax(LDepartment.Columns.Id).ToString()); //var dt = // new Select(LDepartment.Columns.Id).From(LDepartment.Schema.Name).Where(LDepartment.Columns.IPAddress).IsEqualTo // (pitems.IPAddress).ExecuteDataSet().Tables[0]; //return dt.Rows [0][0].ToString(); //.ExecuteDataSet().Tables[0].Rows[0][0].ToString(); } else { return("-1"); //throw new Exception(string.Format("Name:{0} Đã tồn tại", pitems.IPAddress)); } } catch (Exception ex) { throw ex; } }
public static void UpdateDepartment(LDepartment pitems) { try { if (LDepartment.FetchByID(pitems.Id) != null) { pitems.IsNew = false; pitems.Save(); } } catch (Exception ex) { throw ex; } }
private void btnSave_Click(object sender, EventArgs e) { try { txtID.Text = txtID.Text.ToUpper(); if (ValidData()) { switch (vAction) { case action.Insert: var obj = new LDepartment(); obj.SName = Utility.sDbnull(txtName.Text); obj.SDesc = Utility.sDbnull(txtDesc.Text); obj.IsNew = true; obj.Save(); drList = dtList.NewRow(); drList[LDepartment.Columns.Id] = LDepartment.CreateQuery().GetMax(LDepartment.Columns.Id); ApplyData2Datarow(); dtList.Rows.InsertAt(drList, 0); dtList.AcceptChanges(); txtID.Text = Utility.sDbnull(drList[LDepartment.Columns.Id]); vAction = action.Update; break; case action.Update: new Update(LDepartment.Schema.Name).Set(LDepartment.Columns.SName).EqualTo(txtName.Text). Set(LDepartment.Columns.SDesc).EqualTo(txtDesc.Text). Where(LDepartment.Columns.Id).IsEqualTo(Utility.Int32Dbnull(txtID.Text)). Execute(); ApplyData2Datarow(); drList.AcceptChanges(); break; } } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
private void btnSave_Click(object sender, EventArgs e) { try { txtID.Text = txtID.Text.ToUpper(); if (ValidData()) switch (vAction) { case action.Insert: var obj = new LDepartment(); obj.SName = Utility.sDbnull(txtName.Text); obj.SDesc = Utility.sDbnull(txtDesc.Text); obj.IsNew = true; obj.Save(); drList = dtList.NewRow(); drList[LDepartment.Columns.Id] =LDepartment.CreateQuery().GetMax(LDepartment.Columns.Id); ApplyData2Datarow(); dtList.Rows.InsertAt(drList, 0); dtList.AcceptChanges(); txtID.Text = Utility.sDbnull(drList[LDepartment.Columns.Id]); vAction = action.Update; break; case action.Update: new Update(LDepartment.Schema.Name).Set(LDepartment.Columns.SName).EqualTo(txtName.Text). Set(LDepartment.Columns.SDesc).EqualTo(txtDesc.Text). Where(LDepartment.Columns.Id).IsEqualTo(Utility.Int32Dbnull(txtID.Text)). Execute(); ApplyData2Datarow(); drList.AcceptChanges(); break; } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
public void Insert(string SName,string SDesc,string HisDepartmentCode,short? IntOrder) { LDepartment item = new LDepartment(); item.SName = SName; item.SDesc = SDesc; item.HisDepartmentCode = HisDepartmentCode; item.IntOrder = IntOrder; item.Save(UserName); }
public void Update(short Id,string SName,string SDesc,string HisDepartmentCode,short? IntOrder) { LDepartment item = new LDepartment(); item.MarkOld(); item.IsLoaded = true; item.Id = Id; item.SName = SName; item.SDesc = SDesc; item.HisDepartmentCode = HisDepartmentCode; item.IntOrder = IntOrder; item.Save(UserName); }