private void grdData_CurrentRowChanged(object sender) { RFMDataGridView grd = (RFMDataGridView)sender; if (grd.CurrentRow == null || grd.CurrentRow.Index < 0) { return; } int rowIndex = grd.CurrentRow.Index; if (grd.IsStatusRow(rowIndex)) { oWarrantCur.ClearOne(); btnPrint.Enabled = btnService.Enabled = false; } else { DataRow r = ((DataRowView)((DataGridViewRow)grd.Rows[rowIndex]).DataBoundItem).Row; oWarrantCur.FillOne(r); SetButtonStatus(r); } }
private void tmrRestore_Tick(object sender, EventArgs e) { tmrRestore.Enabled = false; RFMDataGridView grd = grdOutputsDocuments; if (grd.CurrentRow == null || grd.CurrentRow.Index < 0) { return; } int rowIndex = grd.CurrentRow.Index; btnOutputsDocumentBring.Enabled = btnOutputsDocumentBringZero.Enabled = false; if (grd.IsStatusRow(rowIndex)) { oOutputDocumentCur.ClearOne(); } else { // заполнение объекта по текущей строке DataRow r = ((DataRowView)((DataGridViewRow)grdOutputsDocuments.Rows[rowIndex]).DataBoundItem).Row; oOutputDocumentCur.FillOne(r); btnOutputsDocumentBring.Enabled = btnOutputsDocumentBringZero.Enabled = oOutputDocumentCur.IsConfirmed && !oOutputDocumentCur.IsBrought; } tcOutputsDocumentsGoods.SetAllNeedRestore(true); }
private void grdInventories_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = (RFMDataGridView)sender; // grdInventories if (grd.DataSource == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { if (grd.Columns[e.ColumnIndex].Name.Contains("Image")) { e.Value = Properties.Resources.Empty; } return; } DataRow r = ((DataRowView)grd.Rows[e.RowIndex].DataBoundItem).Row; switch (grd.Columns[e.ColumnIndex].Name) { case "grcInventories_IsConfirmedImage": if (Convert.ToBoolean(r["IsConfirmed"])) { e.Value = Properties.Resources.Check; } else { e.Value = Properties.Resources.Empty; } break; } }
private void grdData_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = (RFMDataGridView)sender; if (grd.DataSource == null) { return; } if (grd.Rows[e.RowIndex] == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { if (grd.Columns[e.ColumnIndex].Name.ToUpper().Contains("IMAGE")) { e.Value = Properties.Resources.Empty; } return; } if (grd.Name.ToUpper().Contains("GRD")) { if (grd.Columns[e.ColumnIndex].DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } } }
private void grdData_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = grdData; if (grd.Rows[e.RowIndex] == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { e.CellStyle.BackColor = Color.Silver; e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold); switch (grd.Columns[e.ColumnIndex].Name) { case "grcRestQnt_After": case "grcRestQnt_Before": case "grcInBox": e.CellStyle.Format = "### ### ### ###"; break; } return; } DataGridViewRow r = grd.Rows[e.RowIndex]; switch (grd.Columns[e.ColumnIndex].Name) { case "grcRestQnt_After": case "grcRestQnt_Before": case "grcInBox": if (!Convert.IsDBNull(r.Cells["grcWeighting"].Value) && Convert.ToBoolean(r.Cells["grcWeighting"].Value) || !Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value)) { e.CellStyle.Format = "### ### ### ##0.000"; } else { e.CellStyle.Format = "### ### ### ###"; } //if (Convert.IsDBNull(e.Value) || e.Value == null || (decimal)e.Value == 0) // e.Value = ""; break; } if (!Convert.ToBoolean(r.Cells["grcActual"].Value)) { e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Italic); } if (Convert.ToDecimal(r.Cells["grcQnt_After"].Value) != Convert.ToDecimal(r.Cells["grcQnt_Before"].Value)) { grd.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightPink; } else { grd.Rows[e.RowIndex].DefaultCellStyle.BackColor = cDefaultBackColor; } }
private void grdInputsDocuments_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = (RFMDataGridView)sender; if (grd.DataSource == null) { return; } string sGridName = grd.Name.ToUpper(); DataGridViewColumn c = grd.Columns[e.ColumnIndex]; string sColumnName = c.Name.ToUpper(); // статусная строка if (grd.IsStatusRow(e.RowIndex)) { if (sColumnName.Contains("RESULT") || sColumnName.Contains("IMAGE")) { e.Value = Properties.Resources.Empty; } return; } // строка данных DataRow r = ((DataRowView)grd.Rows[e.RowIndex].DataBoundItem).Row; // подтверждение отгрузки и доставки клиенту if (sColumnName.Contains("IsConfirmedImage".ToUpper())) { if ((bool)r["IsConfirmed"]) { e.Value = Properties.Resources.Check; } else { e.Value = Properties.Resources.Empty; } } // нетто-брутто if ((sColumnName.Contains("TTO") || sColumnName.Contains("AMOUNT")) && c.DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } // перенос if ((bool)r["IsCarried"] || !Convert.IsDBNull(r["CopiedFromInputDocumentID"])) { e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold); } // скопированные из задания // ... }
private void grdTrafficsFrames_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = grdTrafficsFrames; if (grd.DataSource == null) { return; } if (grd.Rows[e.RowIndex] == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { switch (grd.Columns[e.ColumnIndex].Name) { case "grcStatusImage": e.Value = Properties.Resources.Empty; break; } return; } switch (grd.Columns[e.ColumnIndex].Name) { case "grcStatusImage": if (grd.Rows[e.RowIndex].Cells["grcDateConfirm"].Value.ToString().Length == 0) { e.Value = Properties.Resources.Empty; } else if (Convert.ToBoolean(grd.Rows[e.RowIndex].Cells["grcSuccess"].Value)) { e.Value = Properties.Resources.Check; } else { e.Value = Properties.Resources.CheckRed; } break; case "grcTrafficsFramesInBox": DataGridViewRow r = grd.Rows[e.RowIndex]; if (!Convert.IsDBNull(r.Cells["grcTrafficsFramesWeighting"].Value) && Convert.ToBoolean(r.Cells["grcTrafficsFramesWeighting"].Value) || !Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value)) { e.CellStyle.Format = "### ### ### ###.000"; } else { e.CellStyle.Format = "### ### ### ###"; } break; } }
private void grdTrips_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (grdTrips.DataSource == null) { return; } RFMDataGridView grd = grdTrips; // статусная строка if (grd.IsStatusRow(e.RowIndex)) { if (grd.Columns[e.ColumnIndex].Name.ToUpper().Contains("IMAGE")) { e.Value = Properties.Resources.Empty; } return; } // строка данных DataRow r = ((DataRowView)((DataGridViewRow)grd.Rows[e.RowIndex]).DataBoundItem).Row; DataGridViewColumn c = grd.Columns[e.ColumnIndex]; oTripTemp.FillOne(r); switch (c.Name) { case "grcTrip_TripStatusImage": switch ((int)r["TripStatus"]) { case 0: e.Value = Properties.Resources.DotGreen; break; case 1: e.Value = Properties.Resources.DotYellow; break; case 2: e.Value = Properties.Resources.DotRed; break; default: e.Value = Properties.Resources.Empty; break; } break; } if (c.Name.Contains("tto") && c.DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void grdCellsContents_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = grdCellsContents; if (grd.Rows[e.RowIndex] == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { e.CellStyle.BackColor = Color.Silver; e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold); switch (grd.Columns[e.ColumnIndex].Name) { case "grcQnt": case "grcQntCollect": case "grcInBox": e.CellStyle.Format = "### ### ### ###"; break; case "grcBoxCollect": e.CellStyle.Format = "### ### ### ###.#"; break; case "grcChangesImage": e.Value = Properties.Resources.Empty; break; } return; } DataGridViewRow r = grd.Rows[e.RowIndex]; switch (grd.Columns[e.ColumnIndex].Name) { case "grcQnt": case "grcQntCollect": case "grcInBox": if (!Convert.IsDBNull(r.Cells["grcWeighting"].Value) && Convert.ToBoolean(r.Cells["grcWeighting"].Value) || !Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value)) { e.CellStyle.Format = "### ### ### ###.000"; } else { e.CellStyle.Format = "### ### ### ###"; } break; case "grcBoxCollect": e.CellStyle.Format = "### ### ### ###.#"; break; } }
private void dgvOutputsDocuments_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { // используется для OutputsDocuments и InputsDocuments RFMDataGridView grd = (RFMDataGridView)sender; if (grd.DataSource == null || grd.Rows.Count == 0) { return; } string sGridName = grd.Name.ToUpper(); DataGridViewColumn c = grd.Columns[e.ColumnIndex]; string sColumnName = c.Name.ToUpper(); // статусная строка if (grd.IsStatusRow(e.RowIndex)) { if (sColumnName.Contains("IMAGE")) { e.Value = Properties.Resources.Empty; } return; } // строка данных DataRow r = ((DataRowView)((DataGridViewRow)grd.Rows[e.RowIndex]).DataBoundItem).Row; if (sColumnName.Contains("Image".ToUpper())) { if ((bool)r["IsBrought"]) { if ((bool)r["SuccessBrought"]) { e.Value = Properties.Resources.Check; } else { e.Value = Properties.Resources.CheckRed; } } else { e.Value = Properties.Resources.Empty; } } // нетто-брутто if (sColumnName.Contains("TTO") && c.DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void grdFramesContents_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = ((RFMDataGridView)sender); if (grd.DataSource == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { e.CellStyle.BackColor = Color.Silver; e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold); switch (grd.Columns[e.ColumnIndex].Name) { case "grcQntFramesContents": case "grcInBox": e.CellStyle.Format = "### ### ### ###"; break; } return; } DataGridViewRow r = grd.Rows[e.RowIndex]; switch (grd.Columns[e.ColumnIndex].Name) { case "grcQntFramesContents": case "grcInBox": if (!Convert.IsDBNull(r.Cells["grcFramesContentsWeighting"].Value) && Convert.ToBoolean(r.Cells["grcFramesContentsWeighting"].Value) || !Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value)) { e.CellStyle.Format = "### ### ### ###.000"; } else { e.CellStyle.Format = "### ### ### ###"; } break; } if ((grd.Columns[e.ColumnIndex].Name.Contains("Qnt") || grd.Columns[e.ColumnIndex].Name.Contains("Box") || grd.Columns[e.ColumnIndex].Name.Contains("Pal")) && grd.Columns[e.ColumnIndex].DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void grdData_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = grdData; if (grd.Rows[e.RowIndex] == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { e.CellStyle.BackColor = Color.Silver; e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold); switch (grd.Columns[e.ColumnIndex].Name) { case "grcTypeImage": e.Value = Properties.Resources.Empty; break; } return; } DataGridViewRow r = grd.Rows[e.RowIndex]; switch (grd.Columns[e.ColumnIndex].Name) { case "grcQntPlus": case "grcQntMinus": if (bWeighting && Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } break; case "grcTypeImage": switch (r.Cells["grcOperType"].Value.ToString()) { case "I": e.Value = Properties.Resources.Plus; break; case "O": e.Value = Properties.Resources.Minus; break; default: e.Value = Properties.Resources.Empty; break; } break; } }
private void grdFramesTraffics_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = ((RFMDataGridView)sender); if (grd.DataSource == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { switch (grd.Columns[e.ColumnIndex].Name) { case "grcTrafficsConfirmedImage": e.Value = Properties.Resources.Empty; break; } return; } DataGridViewRow r = grd.Rows[e.RowIndex]; switch (grd.Columns[e.ColumnIndex].Name) { case "grcTrafficsConfirmedImage": if (grd.Rows[e.RowIndex].Cells["grcTrafficsDateConfirm"].Value.ToString().Length == 0) { e.Value = Properties.Resources.Empty; } else if ((bool)grd.Rows[e.RowIndex].Cells["grcTrafficsSuccess"].Value) { e.Value = Properties.Resources.Check; } else { e.Value = Properties.Resources.CheckRed; } break; } if ((grd.Columns[e.ColumnIndex].Name.Contains("Height") || grd.Columns[e.ColumnIndex].Name.Contains("Weight")) && grd.Columns[e.ColumnIndex].DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void grdInputsDocumentsGoods_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = (RFMDataGridView)sender; if (grd.DataSource == null) { return; } DataGridViewColumn c = grd.Columns[e.ColumnIndex]; string sColumnName = c.Name.ToUpper(); // статусная строка if (grd.IsStatusRow(e.RowIndex)) { if (sColumnName.Contains("RESULT") || sColumnName.Contains("IMAGE")) { e.Value = Properties.Resources.Empty; } return; } // строка данных DataRow r = ((DataRowView)grd.Rows[e.RowIndex].DataBoundItem).Row; if (sColumnName.Contains("QNT") || sColumnName.Contains("INBOX")) { if (!Convert.IsDBNull(r["Weighting"]) && (bool)r["Weighting"] && !Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value)) { e.CellStyle.Format = "### ###.000"; } else { e.CellStyle.Format = "### ###"; } } if ((sColumnName.Contains("QNT") || sColumnName.Contains("BOX") || sColumnName.Contains("PAL")) && c.DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void grdOddmentsSaved_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (grdOddmentsSaved.DataSource == null) { return; } RFMDataGridView grd = grdOddmentsSaved; if (grd.IsStatusRow(e.RowIndex)) { e.CellStyle.BackColor = Color.Silver; e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold); } }
private void grdWayBills_Trips_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (grdWayBills_Trips.DataSource == null) { return; } RFMDataGridView grd = grdWayBills_Trips; // статусная строка if (grd.IsStatusRow(e.RowIndex)) { if (grd.Columns[e.ColumnIndex].Name.Contains("Image")) { e.Value = Properties.Resources.Empty; } return; } // строка данных DataRow r = ((DataRowView)((DataGridViewRow)grd.Rows[e.RowIndex]).DataBoundItem).Row; DataGridViewColumn c = grd.Columns[e.ColumnIndex]; oTripTemp.FillOne(r); switch (c.Name) { case "grcWayBill_Trip_TripConfirmImage": if ((bool)r["IsConfirmed"]) { e.Value = Properties.Resources.Check; } else { e.Value = Properties.Resources.Empty; } break; } if (c.Name.Contains("tto") && c.DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void dgvTrips_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = (RFMDataGridView)sender; if (grd.DataSource == null || grd.Rows.Count == 0) { return; } string sGridName = grd.Name.ToUpper(); DataGridViewColumn c = grd.Columns[e.ColumnIndex]; string sColumnName = c.Name.ToUpper(); // статусная строка if (grd.IsStatusRow(e.RowIndex)) { if (sColumnName.Contains("IMAGE")) { e.Value = Properties.Resources.Empty; } return; } // строка данных DataRow r = ((DataRowView)((DataGridViewRow)grd.Rows[e.RowIndex]).DataBoundItem).Row; if (sColumnName.Contains("Image".ToUpper())) { if ((bool)r["IsConfirmed"]) { e.Value = Properties.Resources.Check; } else { e.Value = Properties.Resources.Empty; } } // себестоимость if (sColumnName.Contains("Cost".ToUpper())) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void grdInputsDocuments_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = (RFMDataGridView)sender; string sGridName = grd.Name.ToUpper(); if (grd.DataSource == null) { return; } // статусная строка if (grd.IsStatusRow(e.RowIndex)) { if (grd.Columns[e.ColumnIndex].Name.ToUpper().Contains("RESULT") || grd.Columns[e.ColumnIndex].Name.ToUpper().Contains("IMAGE")) { e.Value = Properties.Resources.Empty; } return; } // строка данных DataRow r = ((DataRowView)grd.Rows[e.RowIndex].DataBoundItem).Row; DataGridViewColumn c = grd.Columns[e.ColumnIndex]; string sColumnName = c.Name.ToUpper(); if (sColumnName.Contains("IsConfirmedImage".ToUpper())) { if ((bool)r["IsConfirmed"]) { e.Value = Properties.Resources.Check; } else { e.Value = Properties.Resources.Empty; } } if (sColumnName.Contains("TTO") && c.DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void grdData_CurrentRowChanged(object sender) { RFMDataGridView grd = (RFMDataGridView)sender; if (grd.CurrentRow == null || grd.CurrentRow.Index < 0) { return; } int rowIndex = grd.CurrentRow.Index; if (grd.IsStatusRow(rowIndex)) { btnPrint.Enabled = btnService.Enabled = false; } }
private void dgvTrips_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = (RFMDataGridView)sender; if (grd.DataSource == null || grd.Rows.Count == 0) { return; } DataGridViewColumn c = grd.Columns[e.ColumnIndex]; string sColumnName = c.Name.ToUpper(); // статусна¤ строка if (grd.IsStatusRow(e.RowIndex)) { if (sColumnName.Contains("IMAGE")) { e.Value = Properties.Resources.Empty; } return; } // строка данных DataRow r = ((DataRowView)((DataGridViewRow)grd.Rows[e.RowIndex]).DataBoundItem).Row; if (sColumnName.Contains("IMAGE")) { String sType = r["Type"].ToString(); switch (sType) { case "O": e.Value = Properties.Resources.Minus; break; case "I": e.Value = Properties.Resources.Plus; break; case "$": e.Value = Properties.Resources.Car_Red; break; } } }
private void grdData_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = (RFMDataGridView)sender; if (grd.DataSource == null || grd.Rows.Count == 0) { return; } string sColumnName = grd.Columns[e.ColumnIndex].Name.ToUpper(); // статусная строка if (grd.IsStatusRow(e.RowIndex)) { if (sColumnName.Contains("IMAGE")) { e.Value = Properties.Resources.Empty; } return; } // строка данных DataRow r = ((DataRowView)((DataGridViewRow)grd.Rows[e.RowIndex]).DataBoundItem).Row; if (sColumnName.Contains("IsPrintedImage".ToUpper())) { if (!Convert.IsDBNull(r["IsPrinted"])) { if ((bool)r["IsPrinted"]) { e.Value = Properties.Resources.Print; } else { e.Value = Properties.Resources.Empty; } } else { e.Value = Properties.Resources.Empty; } } }
private void grdData_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = (RFMDataGridView)sender; if (grd.DataSource == null) { return; } if (grd.Rows[e.RowIndex] == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { if (grd.Columns[e.ColumnIndex].Name.ToUpper().Contains("IMAGE")) { e.Value = Properties.Resources.Empty; } return; } /* * switch (grd.Columns[e.ColumnIndex].Name) * { * case "grcUserName": * if (grd.Rows[e.RowIndex].Cells["grcDateConfirm"].Value.ToString().Length == 0) * e.Value = Properties.Resources.Empty; * else * if (Convert.ToBoolean(grd.Rows[e.RowIndex].Cells["grcSuccess"].Value)) * e.Value = Properties.Resources.Check; * else * e.Value = Properties.Resources.CheckRed; * break; * } */ }
private void dgvActsGoods_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView dgv = dgvActsGoods; if (dgv.DataSource == null) { return; } DataGridViewColumn c = dgv.Columns[e.ColumnIndex]; string sColumnName = c.Name.ToUpper(); // статусна¤ строка if (dgv.IsStatusRow(e.RowIndex)) { if (sColumnName.Contains("IMAGE")) { e.Value = Properties.Resources.Empty; } return; } DataRow r = ((DataRowView)dgv.Rows[e.RowIndex].DataBoundItem).Row; if (sColumnName.Contains("QNT") || sColumnName.Contains("INBOX")) { if ((!Convert.IsDBNull(r["Weighting"]) && (bool)r["Weighting"]) || (!Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value))) { e.CellStyle.Format = "### ###.000"; } else { e.CellStyle.Format = "### ###"; } } }
private void grdCellsContents_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = grdCellsContents; if (grd.Rows[e.RowIndex] == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { e.CellStyle.BackColor = Color.Silver; e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold); switch (grd.Columns[e.ColumnIndex].Name) { case "grcQnt": case "grcInBox": e.CellStyle.Format = "### ### ### ###"; break; case "grcChangesImage": e.Value = Properties.Resources.Empty; break; } return; } DataGridViewRow r = grd.Rows[e.RowIndex]; string sChanges = (string)r.Cells["grcChanges"].Value; switch (grd.Columns[e.ColumnIndex].Name) { case "grcQnt": case "grcInBox": if (!Convert.IsDBNull(r.Cells["grcWeighting"].Value) && Convert.ToBoolean(r.Cells["grcWeighting"].Value) || !Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value)) { e.CellStyle.Format = "### ### ### ###.000"; } else { e.CellStyle.Format = "### ### ### ###"; } break; case "grcChangesImage": switch (sChanges) { case "D": e.Value = Properties.Resources.Minus; break; case "E": e.Value = Properties.Resources.Edit; break; case "A": e.Value = Properties.Resources.Plus; break; default: e.Value = Properties.Resources.Empty; break; } break; } // цвет строки switch (sChanges) { case "D": grd.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightPink; break; case "E": e.CellStyle.BackColor = Color.LightYellow; break; case "A": e.CellStyle.BackColor = Color.LightGreen; break; default: e.CellStyle.BackColor = grd.DefaultCellStyle.BackColor; break; } }
private void grdGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (((RFMDataGridView)sender).DataSource == null) { return; } RFMDataGridView grd = (RFMDataGridView)sender; string sGrdName = grd.Name; // статусная строка if (grd.IsStatusRow(e.RowIndex)) { if (grd.Columns[e.ColumnIndex].Name.Contains("Image")) { e.Value = Properties.Resources.Empty; } return; } // строка данных DataRow r = ((DataRowView)((DataGridViewRow)grd.Rows[e.RowIndex]).DataBoundItem).Row; DataGridViewColumn c = grd.Columns[e.ColumnIndex]; string sColumnName = c.Name.ToUpper(); if (sColumnName.Contains("TripStatusImage".ToUpper())) { if (!Convert.IsDBNull(r["TripStatus"])) { // 0 не вышла, 1 в пути, 2 пришла switch ((int)r["TripStatus"]) { case 0: e.Value = Properties.Resources.DotRed; break; case 1: e.Value = Properties.Resources.DotYellow; break; case 2: e.Value = Properties.Resources.DotGreen; break; default: e.Value = Properties.Resources.Empty; break; } } else { e.Value = Properties.Resources.Empty; } } if (sColumnName.Contains("_IsConfirmedImage".ToUpper())) { if ((bool)r["IsConfirmed"]) { e.Value = Properties.Resources.Check; } else { e.Value = Properties.Resources.Empty; } } // Netto, Brutto if (c.Name.Contains("tto") && c.DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void grdAuditActsGoods_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = grdAuditActsGoods; if (grd.DataSource == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { if (grd.Columns[e.ColumnIndex].Name.Contains("Image")) { e.Value = Properties.Resources.Empty; } return; } DataGridViewRow r = grd.Rows[e.RowIndex]; switch (grd.Columns[e.ColumnIndex].Name) { case "grcResultImage": if (Convert.ToInt32(r.Cells["grcQntConfirmed"].Value) > 0) { e.Value = Properties.Resources.Plus; } else { if (Convert.ToDecimal(r.Cells["grcQntConfirmed"].Value) < 0) { e.Value = Properties.Resources.Minus; } else { e.Value = Properties.Resources.Empty; } } break; case "grcQntConfirmed": case "grcInBox": if (!Convert.IsDBNull(r.Cells["grcWeighting"].Value) && Convert.ToBoolean(r.Cells["grcWeighting"].Value) || !Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value)) { e.CellStyle.Format = "### ### ### ###.000"; } else { e.CellStyle.Format = "### ### ### ###"; } break; } if ((grd.Columns[e.ColumnIndex].Name.Contains("Qnt") || grd.Columns[e.ColumnIndex].Name.Contains("Box") || grd.Columns[e.ColumnIndex].Name.Contains("Pal")) && grd.Columns[e.ColumnIndex].DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void grdInputsFrames_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = grdInputsFrames; if (grd.DataSource == null) { return; } if (grd.Rows[e.RowIndex] == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { switch (grd.Columns[e.ColumnIndex].Name) { case "grcInputConfirmed": e.Value = Properties.Resources.Empty; break; case "grcFrameQnt": case "grcFrameInBox": e.CellStyle.Format = "### ### ### ###"; break; } return; } DataGridViewRow r = grd.Rows[e.RowIndex]; switch (grd.Columns[e.ColumnIndex].Name) { case "grcInputConfirmed": if ((r.Cells["grcInputDateConfirm"].Value != DBNull.Value)) { e.Value = Properties.Resources.Check; } else { e.Value = Properties.Resources.Empty; } break; case "grcFrameQnt": case "grcFrameInBox": if (!Convert.IsDBNull(r.Cells["grcWeightingFrame"].Value) && Convert.ToBoolean(r.Cells["grcWeightingFrame"].Value) || !Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value)) { e.CellStyle.Format = "### ### ### ###.000"; } else { e.CellStyle.Format = "### ### ### ###"; } break; } if ((grd.Columns[e.ColumnIndex].Name.Contains("Qnt") || grd.Columns[e.ColumnIndex].Name.Contains("Box") || grd.Columns[e.ColumnIndex].Name.Contains("Pal") || grd.Columns[e.ColumnIndex].Name.Contains("Weight")) && grd.Columns[e.ColumnIndex].DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void grdInventoriesCells_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { RFMDataGridView grd = grdInventoriesCells; if (grd.DataSource == null) { return; } if (grd.IsStatusRow(e.RowIndex)) { switch (grd.Columns[e.ColumnIndex].Name) { case "grcIsCellConfirmedImage": case "grcIsCellSuccessImage": e.Value = Properties.Resources.Empty; break; } return; } DataRow dr = ((DataRowView)grd.Rows[e.RowIndex].DataBoundItem).Row; switch (grd.Columns[e.ColumnIndex].Name) { case "grcIsCellSuccessImage": if (Convert.IsDBNull(dr["Success"])) { e.Value = Properties.Resources.Empty; } else { if (Convert.ToBoolean(dr["Success"])) { e.Value = Properties.Resources.Check; } else { e.Value = Properties.Resources.CheckRed; } } break; case "grcInBox": case "grcQntWished": case "grcQntConfirmed": case "grcQntDiff": if (Convert.IsDBNull(dr["GoodWeighting"]) || Convert.ToBoolean(dr["GoodWeighting"]) || !Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value)) { e.CellStyle.Format = "### ### ### ##0.000"; } else { e.CellStyle.Format = "### ### ### ###"; } break; case "grcBoxWished": case "grcBoxConfirmed": case "grcBoxDiff": if (!Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } break; } }
private void grdOddmentsSavedGoods_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (grdOddmentsSavedGoods.DataSource == null) { return; } RFMDataGridView grd = grdOddmentsSavedGoods; if (grd.IsStatusRow(e.RowIndex)) { e.CellStyle.BackColor = Color.Silver; e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold); switch (grd.Columns[e.ColumnIndex].Name) { case "grcOddmentsSavedResultImage": e.Value = Properties.Resources.Empty; break; case "grcOddmentsSavedQnt": case "grcOddmentsSavedCalcQnt": case "grcOddmentsSavedDiffQnt": case "grcOddmentsSavedInBox": e.CellStyle.Format = "### ### ### ###"; break; } return; } DataGridViewRow r = grd.Rows[e.RowIndex]; switch (grd.Columns[e.ColumnIndex].Name) { case "grcOddmentsSavedResultImage": decimal nQnt = Convert.ToDecimal(r.Cells["grcOddmentsSavedQnt"].Value); if (nQnt > 0) { e.Value = Properties.Resources.DotGreen; } if (nQnt == 0) { e.Value = Properties.Resources.DotYellow; } if (nQnt < 0) { e.Value = Properties.Resources.DotRed; } break; case "grcOddmentsSavedQnt": case "grcOddmentsSavedCalcQnt": case "grcOddmentsSavedDiffQnt": case "grcOddmentsSavedInBox": if (!Convert.IsDBNull(r.Cells["grcOddmentsSavedWeighting"].Value) && Convert.ToBoolean(r.Cells["grcOddmentsSavedWeighting"].Value) || Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value)) { e.CellStyle.Format = "### ### ### ###.000"; } else { e.CellStyle.Format = "### ### ### ###"; } break; } if ((grd.Columns[e.ColumnIndex].Name.Contains("Qnt") || grd.Columns[e.ColumnIndex].Name.Contains("Box") || grd.Columns[e.ColumnIndex].Name.Contains("Pal")) && grd.Columns[e.ColumnIndex].DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }
private void grdOddmentsDetails_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (grdOddmentsDetails.DataSource == null) { return; } RFMDataGridView grd = grdOddmentsDetails; if (grd.IsStatusRow(e.RowIndex)) { e.CellStyle.BackColor = Color.Silver; e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold); switch (grd.Columns[e.ColumnIndex].Name) { case "grcOddmentDetailImage": case "grcLockedImage": e.Value = Properties.Resources.Empty; break; case "grcOddmentDetailQnt": e.CellStyle.Format = "### ### ### ###"; break; } return; } DataGridViewRow r = grd.Rows[e.RowIndex]; switch (grd.Columns[e.ColumnIndex].Name) { case "grcOddmentDetailImage": if (r.Cells["grcDateValidPercent"].Value == DBNull.Value) { e.Value = Properties.Resources.Empty; } else { decimal nDateValidPercent = Convert.ToDecimal(r.Cells["grcDateValidPercent"].Value); if (nDateValidPercent < 20) { e.Value = Properties.Resources.Plain_R; } if (nDateValidPercent >= 20 && nDateValidPercent < 50) { e.Value = Properties.Resources.Plain_Y; } if (nDateValidPercent >= 50 && nDateValidPercent < 67) { e.Value = Properties.Resources.Plain_G; } if (nDateValidPercent >= 67) { e.Value = Properties.Resources.Plain_B; } } break; case "grcLockedImage": if (Convert.ToBoolean(r.Cells["grcLocked"].Value)) { e.Value = Properties.Resources.Lock1; } else { e.Value = Properties.Resources.Empty; } break; case "grcOddmentDetailQnt": if (!Convert.IsDBNull(r.Cells["grcOddmentDetailWeighting"].Value) && Convert.ToBoolean(r.Cells["grcOddmentDetailWeighting"].Value) || !Convert.IsDBNull(e.Value) && Convert.ToDecimal(e.Value) != Convert.ToInt32(e.Value)) { e.CellStyle.Format = "### ### ### ###.000"; } else { e.CellStyle.Format = "### ### ### ###"; } break; } if ((grd.Columns[e.ColumnIndex].Name.Contains("Qnt") || grd.Columns[e.ColumnIndex].Name.Contains("Box") || grd.Columns[e.ColumnIndex].Name.Contains("Pal")) && grd.Columns[e.ColumnIndex].DefaultCellStyle.Format.Contains("N")) { if (Convert.IsDBNull(e.Value) || Convert.ToDecimal(e.Value) == 0) { e.Value = ""; } } }