private void btnActiveDev_Click(object sender, EventArgs e) { if (grdDevice.SelectedRow != null) { _deviceCode = Convert.ToInt32(grdDevice.SelectedRow["Code"]); txtBusDevise.Text = grdDevice.SelectedRow["DeviceID"].ToString(); txtInstaller.Text = grdDevice.SelectedRow["InstallerName"].ToString(); JBusDevise device = new JBusDevise(_deviceCode); txtBusDevise.Tag = device.DeviceCode; txtInstaller.Tag = device.Installer; txtStartDateDevise.Date = device.StartDate; txtEndDateDevise.Date = device.EndDate; btnAddDevice.Text = ClassLibrary.JLanguages._Text("Save..."); } }
private void btnDevActiveDev_Click(object sender, EventArgs e) { if (grdDevice.SelectedRow != null) { if (JMessages.Question("آیا می خواهید باجه دار انتخاب شده حذف شود؟", "حذف؟") == System.Windows.Forms.DialogResult.Yes) { _deviceCode = Convert.ToInt32(grdDevice.SelectedRow["Code"]); JBusDevise device = new JBusDevise(_deviceCode); if (device.Delete()) { LoadDevice(); } _deviceCode = 0; } } }
//private void SaveDevice() //{ // DataTable DT = (DataTable)jJanusGridDevice.DataSource; // if (DT != null) // { // for (int i = 0; i < DT.Rows.Count; i++) // { // DataRow DR = DT.Rows[i]; // JBusDeviseTable BusDeviseTable = new JBusDeviseTable(); // if (DR.RowState == DataRowState.Added) // { // JOwnerTable.SetToClassField(BusDeviseTable, DR); // DR["Code"] = BusDeviseTable.Insert(); // } // else // if (DR.RowState == DataRowState.Deleted) // { // DR.RejectChanges(); // JOwnerTable.SetToClassField(BusDeviseTable, DR); // BusDeviseTable.Delete(); // DR.Delete(); // } // else // if (DR.RowState == DataRowState.Modified) // { // JOwnerTable.SetToClassField(BusDeviseTable, DR); // BusDeviseTable.Update(); // } // DR.AcceptChanges(); // } // } //} private bool SaveDevice() { bool result = false; if (txtBusDevise.Tag == null || (int)txtBusDevise.Tag == 0) { JMessages.Error("لطفا دستگاه را انتخاب کنید", "خطا"); return(false); } if (txtStartDateDevise.Date == DateTime.MinValue) { JMessages.Error("لطفا تاریخ شروع را وارد کنید", "خطا"); return(false); } if (txtEndDateDevise.Date != DateTime.MinValue && txtStartDateDevise.Date > txtEndDateDevise.Date) { JMessages.Error("لطفا تاریخ شروع و پایان را بصورت صحیح وارد کنید", "خطا"); return(false); } JBusDevise device = new JBusDevise(_deviceCode); device.DeviceCode = (int)txtBusDevise.Tag; device.Installer = (int)txtInstaller.Tag; device.StartDate = txtStartDateDevise.Date; device.EndDate = txtEndDateDevise.Date; device.BusCode = _Code; if (_deviceCode == 0) { result = device.Insert() > 0; } else { result = device.Update(); } if (result) { LoadDevice(); } btnAddDevice.Text = ClassLibrary.JLanguages._Text("Add"); _deviceCode = 0; return(result); }