/// <summary> /// Bind data to grid /// </summary> /// <author>Trada</author> /// <date>Monday, June 13 2005</date> protected virtual void BindDataToGrid() { int pintCCN = int.Parse(cboCCN.SelectedValue.ToString()); int pintMasLoc = voMasLoc.MasterLocationID; DateTime pdtmFromDueDate = DateTime.MinValue; DateTime pdtmToDueDate = DateTime.MinValue; if (dtmFromDueDate.Value != null && !dtmFromDueDate.ValueIsDbNull) { pdtmFromDueDate = (DateTime)dtmFromDueDate.Value; } if (dtmToDueDate.Value != null && !dtmToDueDate.ValueIsDbNull) { pdtmToDueDate = (DateTime)dtmToDueDate.Value; } //List release WOs ManufacturingCloseBO boManufacturingClose = new ManufacturingCloseBO(); dstReleaseWO = boManufacturingClose.SearchReleasedWO(pintCCN, pintMasLoc, pdtmFromDueDate, pdtmToDueDate); foreach (DataRow drow in dstReleaseWO.Tables[0].Rows) { drow[SELECT] = false; } gridWOClose.DataSource = dstReleaseWO.Tables[0]; FormControlComponents.RestoreGridLayout(gridWOClose, dtbGridLayOut); gridWOClose.Splits[0].DisplayColumns[SELECT].DataColumn.ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox; gridWOClose.Splits[0].DisplayColumns[SELECT].Style.HorizontalAlignment = AlignHorzEnum.Center; //Lock all columns in grid gridWOClose.Splits[0].DisplayColumns[PRO_WorkOrderMasterTable.WORKORDERNO_FLD].Locked = true; gridWOClose.Splits[0].DisplayColumns[PRO_WorkOrderDetailTable.LINE_FLD].Locked = true; gridWOClose.Splits[0].DisplayColumns[OPENQUANTITY].Locked = true; gridWOClose.Splits[0].DisplayColumns[ITM_CategoryTable.TABLE_NAME + ITM_CategoryTable.CODE_FLD].Locked = true; gridWOClose.Columns[OPENQUANTITY].NumberFormat = Constants.EDIT_NUM_MASK; gridWOClose.Splits[0].DisplayColumns[PARTNUMBER].Locked = true; gridWOClose.Splits[0].DisplayColumns[CAPTION_UM].Locked = true; gridWOClose.Splits[0].DisplayColumns[PRO_WorkOrderDetailTable.STARTDATE_FLD].Locked = true; gridWOClose.Columns[PRO_WorkOrderDetailTable.STARTDATE_FLD].NumberFormat = Constants.DATETIME_FORMAT_HOUR; gridWOClose.Splits[0].DisplayColumns[PRO_WorkOrderDetailTable.DUEDATE_FLD].Locked = true; gridWOClose.Columns[PRO_WorkOrderDetailTable.DUEDATE_FLD].NumberFormat = Constants.DATETIME_FORMAT_HOUR; gridWOClose.Splits[0].DisplayColumns[ITM_ProductTable.DESCRIPTION_FLD].Locked = true; gridWOClose.Splits[0].DisplayColumns[ITM_ProductTable.REVISION_FLD].Locked = true; //Invisible some columns gridWOClose.Splits[0].DisplayColumns[PRO_WorkOrderDetailTable.WORKORDERDETAILID_FLD].Visible = false; dstReleaseWO.AcceptChanges(); //Set new status for chkSelectAll if (gridWOClose.RowCount == 0) { chkSelectAllManuf.Checked = false; } else { for (int i = 0; i < gridWOClose.RowCount; i++) { if (gridWOClose[i, SELECT].ToString().Trim() != TRUE) { chkSelectAllManuf.Checked = false; return; } } chkSelectAllManuf.Checked = true; } }
/// <summary> /// Close WOs has been selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <author>Trada</author> /// <date>Friday, June 10 2005</date> protected virtual void btnCloseWO_Click(object sender, System.EventArgs e) { const string METHOD_NAME = THIS + ".btnCloseWO_Click()"; try { if (dtmPostDate.Value == null) { PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID, MessageBoxIcon.Error); dtmPostDate.Focus(); dtmPostDate.Select(); return; } //Check date in period if (!FormControlComponents.CheckDateInCurrentPeriod(DateTime.Parse(dtmPostDate.Value.ToString()))) { PCSMessageBox.Show(ErrorCode.MESSAGE_RGV_POSTDATE_PERIOD); dtmPostDate.Focus(); dtmPostDate.Select(); return; } if (dtmPostDate.Text == string.Empty) { PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID, MessageBoxIcon.Error); dtmPostDate.Focus(); return; } if (gridWOClose.RowCount == 0) { throw new PCSException(ErrorCode.MESSAGE_PO_APPROVE_NO_DATA_IN_GRID, METHOD_NAME, null); } if (CheckDataGridToRelease()) { StoreSelectedLines(); ManufacturingCloseBO boManuf = new ManufacturingCloseBO(); boManuf.CloseWorkOrderLines(DateTime.Parse(dtmPostDate.Value.ToString()), arrSelectedLines); if (PCSMessageBox.Show(ErrorCode.MESSAGE_AFTER_SAVE_DATA) == DialogResult.OK) { BindDataToGrid(); } } else { PCSMessageBox.Show(ErrorCode.MESSAGE_RELEASE_WO_SELECT_WOLINE, MessageBoxIcon.Error); } } catch (PCSException ex) { // Displays the error message if throwed from PCSException. PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error); try { // Log error message into log file. Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR); } catch { // Show message if logger has an error. PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error); } } catch (Exception ex) { // displays the error message. PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error); // log message. try { Logger.LogMessage(ex, METHOD_NAME, Level.ERROR); } catch { PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error); } } }