private void cmdDelete_Click(object sender, EventArgs e) { try { if (grdTestData.CurrentRow != null && grdTestData.CurrentRow.RowType == RowType.Record) { //if (DDataControl.CreateQuery().WHERE(DDataControl.Columns.TestDataId, Utility.sDbnull(grdTestData.GetValue("TestData_ID"))).GetRecordCount() > 0 | // TResultDetail.CreateQuery().WHERE(TResultDetail.Columns.TestDataId, Utility.sDbnull(grdTestData.GetValue("TestData_ID"))).GetRecordCount() > 0) if (DDataControl.CreateQuery().WHERE(DDataControl.Columns.TestDataId, Utility.sDbnull(grdTestData.GetValue("TestData_ID"))).GetRecordCount() > 0 ) { Utility.ShowMsg(string.Format("{0} đang sử dụng. Không được xóa.", grdTestData.GetValue("TestData_ID"))); } else if ( Utility.AcceptQuestion( string.Format("Xóa {0} của {1}", grdTestData.GetValue("Data_Name"), grdTestData.GetValue("TestType_Name")), "Thông báo", true)) { new Delete().From(LStandardTest.Schema.Name).Where(LStandardTest.Columns.TestDataId).IsEqualTo( grdTestData.GetValue("TestData_ID")).Execute(); grdTestData.CurrentRow.Delete(); grdTestData.UpdateData(); dtTestDataList.AcceptChanges(); } } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
public static string InsertDataControl(DDataControl pitems) { int i = 0; Query _QueryRS = DDataControl.CreateQuery(); try { //if ((!DDataControl.FetchByParameter(DDataControl.Columns.DataName, Comparison.Equals, pitems.DataName). // Read()) && // (!DDataControl.FetchByParameter(DDataControl.Columns.AliasName, Comparison.Equals, pitems.AliasName) // .Read())) //{ pitems.IsNew = true; pitems.Save(i); return(_QueryRS.GetMax(DDataControl.Columns.DataControlId).ToString()); //} //else //{ // return "-1"; //} } catch (Exception ex) { throw ex; } }
private void ActionDevice(action vAction) { try { if (grdDevice.CurrentRow == null && (vAction == action.Update || vAction == action.Delete)) { return; } switch (vAction) { case action.Normal: dtDevice = new Select(DDeviceList.Schema.Name + ".*", TTestTypeList.Columns.TestTypeName, LManufacture.Columns.SName) .From(DDeviceList.Schema.Name). LeftOuterJoin(TTestTypeList.TestTypeIdColumn, DDeviceList.TestTypeIdColumn). LeftOuterJoin(LManufacture.IdColumn, DDeviceList.ManufactureIdColumn). ExecuteDataSet().Tables[0]; grdDevice.DataSource = dtDevice; break; case action.Delete: if ( DDataControl.CreateQuery().WHERE(DDataControl.Columns.DeviceId, Utility.Int32Dbnull(grdDevice.GetValue("Device_ID"))). GetRecordCount() > 0) { Utility.ShowMsg("Danh mục đang được sử dụng. Không được xóa"); return; } if (Utility.AcceptQuestion("Thực hiện xóa " + grdDevice.GetValue("Device_Name"), "Thông báo", true)) { new Delete().From(DDeviceList.Schema.Name).Where(DDeviceList.Columns.DeviceId).IsEqualTo( Utility.Int32Dbnull(grdDevice.GetValue("Device_ID"))).Execute(); grdDevice.CurrentRow.Delete(); grdDevice.UpdateData(); } dtDevice.AcceptChanges(); break; default: var oForm = new frmDeviceList_AU(); oForm.vAction = vAction; oForm.drList = Utility.GetDataRow(dtDevice, DDeviceList.Columns.DeviceId, grdDevice.GetValue("Device_ID")); oForm.dtList = dtDevice; oForm.ShowDialog(); break; } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
public static void DeleteDataControl(int pId) { try { if (DDataControl.FetchByID(pId) != null) { DDataControl.Delete(pId); } } catch (Exception ex) { throw ex; } }
public static void UpdateDataControl(DDataControl pitems) { try { if (DDataControl.FetchByID(pitems.DataControlId) != null) { pitems.IsNew = false; pitems.Save(); } } catch (Exception ex) { throw ex; } }
public void Update(decimal DataControlId, decimal DeviceId, int DataTypeId, int?DataSequence, bool?ControlType, string DataName, string AliasName, string MeasureUnit, short DataPoint, string NormalLevel, string NormalLevelW, bool?DataView, bool?DataPrint, string DataType, string Description, string TestDataId, string SCondition, string SFormula, short?ForceRun) { DDataControl item = new DDataControl(); item.MarkOld(); item.IsLoaded = true; item.DataControlId = DataControlId; item.DeviceId = DeviceId; item.DataTypeId = DataTypeId; item.DataSequence = DataSequence; item.ControlType = ControlType; item.DataName = DataName; item.AliasName = AliasName; item.MeasureUnit = MeasureUnit; item.DataPoint = DataPoint; item.NormalLevel = NormalLevel; item.NormalLevelW = NormalLevelW; item.DataView = DataView; item.DataPrint = DataPrint; item.DataType = DataType; item.Description = Description; item.TestDataId = TestDataId; item.SCondition = SCondition; item.SFormula = SFormula; item.ForceRun = ForceRun; item.Save(UserName); }
private void cmdSave_Click(object sender, EventArgs e) { try { txtID.Text = txtID.Text.ToUpper(); if (ValidData()) { switch (vAction) { case action.Insert: var obj = new DDataControl(); obj.DataName = ""; obj.DeviceId = Utility.Int32Dbnull(cboDevice.SelectedValue, -1); obj.DataTypeId = 0; obj.ControlType = true; obj.AliasName = Utility.sDbnull(txtAlias.Text); obj.Description = Utility.sDbnull(txtDesc.Text); obj.IsNew = true; obj.Save(); drData = dtDataControl.NewRow(); drData[DDataControl.Columns.DataControlId] = DDataControl.CreateQuery().WHERE(DDataControl.Columns.DeviceId, Utility.Int32Dbnull(cboDevice.SelectedValue, -1)). WHERE(DDataControl.Columns.AliasName, txtAlias.Text).GetMax(DDataControl.Columns.DataControlId); txtID.Text = drData[DDataControl.Columns.DataControlId].ToString(); ApplyData2Datarow(); dtDataControl.Rows.InsertAt(drData, 0); dtDataControl.AcceptChanges(); vAction = action.Update; break; case action.Update: new Update(DDataControl.Schema.Name).Set(DDataControl.Columns.AliasName).EqualTo(txtAlias.Text). Set(DDataControl.Columns.Description).EqualTo(txtDesc.Text). Set(DDataControl.Columns.DeviceId).EqualTo(Utility.Int32Dbnull(cboDevice.SelectedValue, -1)). Where(DDataControl.Columns.DataControlId).IsEqualTo(Utility.Int32Dbnull(txtID.Text, -1)).Execute(); ApplyData2Datarow(); drData.AcceptChanges(); break; } } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
public static void DeleteDevice(int pId) { try { if (DDeviceList.FetchByID(pId) != null) { new Delete().From(DDeviceList.Schema) .Where(DDeviceList.Columns.DeviceId).IsEqualTo(pId) .Execute(); DDataControl.Delete(DDataControl.Columns.DeviceId, pId); } } catch (Exception ex) { throw ex; } }
private void cmdSave_Click(object sender, EventArgs e) { try { txtID.Text = txtID.Text.ToUpper(); if (ValidData()) switch (vAction) { case action.Insert: var obj = new DDataControl(); obj.DataName = ""; obj.DeviceId = Utility.Int32Dbnull(cboDevice.SelectedValue, -1); obj.DataTypeId = 0; obj.ControlType = true; obj.AliasName = Utility.sDbnull(txtAlias.Text); obj.Description = Utility.sDbnull(txtDesc.Text); obj.IsNew = true; obj.Save(); drData = dtDataControl.NewRow(); drData[DDataControl.Columns.DataControlId] = DDataControl.CreateQuery().WHERE(DDataControl.Columns.DeviceId,Utility.Int32Dbnull(cboDevice.SelectedValue, -1)). WHERE(DDataControl.Columns.AliasName, txtAlias.Text).GetMax(DDataControl.Columns.DataControlId); txtID.Text = drData[DDataControl.Columns.DataControlId].ToString(); ApplyData2Datarow(); dtDataControl.Rows.InsertAt(drData, 0); dtDataControl.AcceptChanges(); vAction=action.Update; break; case action.Update: new Update(DDataControl.Schema.Name).Set(DDataControl.Columns.AliasName).EqualTo(txtAlias.Text). Set(DDataControl.Columns.Description).EqualTo(txtDesc.Text). Set(DDataControl.Columns.DeviceId).EqualTo(Utility.Int32Dbnull(cboDevice.SelectedValue,-1)). Where(DDataControl.Columns.DataControlId).IsEqualTo(Utility.Int32Dbnull(txtID.Text,-1)).Execute(); ApplyData2Datarow(); drData.AcceptChanges(); break; } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
public bool Destroy(object DataControlId) { return(DDataControl.Destroy(DataControlId) == 1); }
public bool Delete(object DataControlId) { return(DDataControl.Delete(DataControlId) == 1); }
public void Insert(decimal DeviceId,int DataTypeId,int? DataSequence,bool? ControlType,string DataName,string AliasName,string MeasureUnit,short DataPoint,string NormalLevel,string NormalLevelW,bool? DataView,bool? DataPrint,string DataType,string Description,string TestDataId,string SCondition,string SFormula,short? ForceRun) { DDataControl item = new DDataControl(); item.DeviceId = DeviceId; item.DataTypeId = DataTypeId; item.DataSequence = DataSequence; item.ControlType = ControlType; item.DataName = DataName; item.AliasName = AliasName; item.MeasureUnit = MeasureUnit; item.DataPoint = DataPoint; item.NormalLevel = NormalLevel; item.NormalLevelW = NormalLevelW; item.DataView = DataView; item.DataPrint = DataPrint; item.DataType = DataType; item.Description = Description; item.TestDataId = TestDataId; item.SCondition = SCondition; item.SFormula = SFormula; item.ForceRun = ForceRun; item.Save(UserName); }