private void BtnMaintenanceItem_Click(object sender, EventArgs e) { if (dgvMaintenance.CurrentRow != null) { var maintenanceId = Convert.ToInt32(dgvMaintenance.CurrentRow.Cells["intID"].Value.ToString()); FrmMaintenanceItems frmMaintenanceItems = new FrmMaintenanceItems(); frmMaintenanceItems.maintenanceId = maintenanceId; using (UnitOfWork db = new UnitOfWork()) { var maintenance = db.Maintenance.GetEntity(t => t.intID == maintenanceId); frmMaintenanceItems.coIdsWorker = maintenance.nvcCoIdsWorkGroup; } frmMaintenanceItems.Show(); } else { RtlMessageBox.Show("لطفا یک سطر را مشخص کنید", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtmInsert_Click(object sender, EventArgs e) { using (UnitOfWork db = new UnitOfWork()) { var selectItem = dgvMaintenance.Rows.Cast <DataGridViewRow>().FirstOrDefault(t => Convert.ToBoolean(t.Cells["bitSelect"].Value) == true); if (selectItem != null) { FrmMaintenanceItems frmMaintenanceItems = new FrmMaintenanceItems(); int intId = Convert.ToInt32(dgvMaintenance.CurrentRow.Cells["intID"].Value.ToString()); var maintenances = db.Maintenance.GetEntity(t => t.intID == intId); frmMaintenanceItems.coIdsWorker = maintenances.nvcCoIdsWorkGroup; frmMaintenanceItems.maintenanceId = maintenances.intID; frmMaintenanceItems.Show(); } else { FrmMaintenanceInsert frmMaintenanceInsert = new FrmMaintenanceInsert(); frmMaintenanceInsert.Show(); } } }
private void BtmOK_Click(object sender, EventArgs e) { using (UnitOfWork db = new UnitOfWork()) { var shiftId = db.shift.GetEntity(t => t.nvcName == cbShift.SelectedItem).intNumber; var subDepartmentId = db.subDepartment.GetEntity(t => t.nvcName == cbSubDepartment.SelectedItem).intNumber; var coIds = ""; var coIdLeader = txtLeaderWorkGroup.Text; var nameWorker = lbWorkers.Items; foreach (var item in nameWorker) { coIds += db.Employees.GetEntity(t => t.nvcFirstname + " " + t.nvcLastname == item).nvcCoID + "-"; //coIdLeader = db.Employees.GetEntity(t => // t.nvcFirstname + " " + t.nvcLastname == item && t.bitIsLeader == true).nvcCoID; } coIds = coIds.Remove(coIds.Length - 1); //var coIdLeader = db.Employees.GetEntity(t => t.nvcFirstname + " " + t.nvcLastname == txtLeaderWorkGroup.Text).nvcCoID; tabMaintenances tabMaintenances = new tabMaintenances() { intDepartment = 5, bitSelect = false, datWorkGroup = dtMaintenance.Value, intShift = shiftId, intSubDepartment = subDepartmentId, nvcCoIdsWorkGroup = coIds, nvcCoIdLeader = coIdLeader, intWourkGroup = (int)cbWorkGroup.SelectedItem }; var maintenancInsert = db.Maintenance.Insert(tabMaintenances); db.Save(); this.Close(); FrmMaintenanceItems frmMaintenanceItems = new FrmMaintenanceItems(); frmMaintenanceItems.coIdsWorker = tabMaintenances.nvcCoIdsWorkGroup; frmMaintenanceItems.maintenanceId = maintenancInsert.intID; frmMaintenanceItems.Show(); } }