/// <summary> /// Hàm insert Loại xét nghiệm /// </summary> /// <param name="pitems"></param> /// <returns></returns> public static string InsertTestTypeList(TTestTypeList pitems) { int i = 0; Query queryRs = TTestTypeList.CreateQuery(); try { if ( !TTestTypeList.FetchByParameter(TTestTypeList.Columns.TestTypeId, Comparison.Equals, pitems.TestTypeId).Read()) { pitems.IsNew = true; pitems.Save(i); return(queryRs.GetMax(TTestTypeList.Columns.TestTypeId).ToString()); } else { return("-1"); //throw new Exception(string.Format("Name:{0} Đã tồn tại", pitems.IPAddress)); } } 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 TTestTypeList(); obj.TestTypeName = Utility.sDbnull(txtName.Text); obj.IntOrder = Utility.ByteDbnull(txtSequence.Value); obj.Abbreviation = Utility.sDbnull(txtAbbreviation.Text); obj.Note = Utility.sDbnull(txtDesc.Text); obj.Price = Utility.DecimaltoDbnull(txtPrice.Value); obj.PrintDetail = Utility.ByteDbnull(ckbPrintDetail.Checked ? 1 : 0); obj.IsNew = true; obj.Save(); drList = dtList.NewRow(); drList[TTestTypeList.Columns.TestTypeId] = TTestTypeList.CreateQuery().GetMax(TTestTypeList.Columns.TestTypeId); ApplyData2Datarow(); dtList.Rows.InsertAt(drList, 0); dtList.AcceptChanges(); txtID.Text = Utility.sDbnull(drList[TTestTypeList.Columns.TestTypeId]); vAction = action.Update; break; case action.Update: new Update(TTestTypeList.Schema.Name).Set(TTestTypeList.Columns.TestTypeName).EqualTo( txtName.Text). Set(TTestTypeList.Columns.IntOrder).EqualTo(txtSequence.Value). Set(TTestTypeList.Columns.Abbreviation).EqualTo(txtAbbreviation.Text). Set(TTestTypeList.Columns.Note).EqualTo(txtDesc.Text). Set(TTestTypeList.Columns.Price).EqualTo(txtPrice.Value). Set(TTestTypeList.Columns.PrintDetail).EqualTo( Utility.ByteDbnull(ckbPrintDetail.Checked ? 1 : 0)). Where(TTestTypeList.Columns.TestTypeId).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 TTestTypeList(); obj.TestTypeName = Utility.sDbnull(txtName.Text); obj.IntOrder = Utility.ByteDbnull(txtSequence.Value); obj.Abbreviation = Utility.sDbnull(txtAbbreviation.Text); obj.Note = Utility.sDbnull(txtDesc.Text); obj.Price = Utility.DecimaltoDbnull(txtPrice.Value); obj.PrintDetail = Utility.ByteDbnull(ckbPrintDetail.Checked ? 1 : 0); obj.IsNew = true; obj.Save(); drList = dtList.NewRow(); drList[TTestTypeList.Columns.TestTypeId] = TTestTypeList.CreateQuery().GetMax(TTestTypeList.Columns.TestTypeId); ApplyData2Datarow(); dtList.Rows.InsertAt(drList, 0); dtList.AcceptChanges(); txtID.Text = Utility.sDbnull(drList[TTestTypeList.Columns.TestTypeId]); vAction = action.Update; break; case action.Update: new Update(TTestTypeList.Schema.Name).Set(TTestTypeList.Columns.TestTypeName).EqualTo( txtName.Text). Set(TTestTypeList.Columns.IntOrder).EqualTo(txtSequence.Value). Set(TTestTypeList.Columns.Abbreviation).EqualTo(txtAbbreviation.Text). Set(TTestTypeList.Columns.Note).EqualTo(txtDesc.Text). Set(TTestTypeList.Columns.Price).EqualTo(txtPrice.Value). Set(TTestTypeList.Columns.PrintDetail).EqualTo( Utility.ByteDbnull(ckbPrintDetail.Checked ? 1 : 0)). Where(TTestTypeList.Columns.TestTypeId).IsEqualTo(Utility.Int32Dbnull(txtID.Text)). Execute(); ApplyData2Datarow(); drList.AcceptChanges(); break; } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
/// <summary> /// Hàm Update dữ liệu trên Grid /// </summary> /// <param name="pitems"></param> public static void UpdateTestTypeList(TTestTypeList pitems) { try { if (TTestTypeList.FetchByID(pitems.TestTypeId) != null) { pitems.IsNew = false; pitems.Save(); } } catch (Exception ex) { throw ex; } }
public void Insert(string TestTypeName,string Note,short? IntOrder,short? PrintDetail,decimal? Price,string Abbreviation) { TTestTypeList item = new TTestTypeList(); item.TestTypeName = TestTypeName; item.Note = Note; item.IntOrder = IntOrder; item.PrintDetail = PrintDetail; item.Price = Price; item.Abbreviation = Abbreviation; item.Save(UserName); }
public void Update(int TestTypeId,string TestTypeName,string Note,short? IntOrder,short? PrintDetail,decimal? Price,string Abbreviation) { TTestTypeList item = new TTestTypeList(); item.MarkOld(); item.IsLoaded = true; item.TestTypeId = TestTypeId; item.TestTypeName = TestTypeName; item.Note = Note; item.IntOrder = IntOrder; item.PrintDetail = PrintDetail; item.Price = Price; item.Abbreviation = Abbreviation; item.Save(UserName); }