private void RefreshEditProductGrid() { editStockGrid.Rows.Clear(); editProductHistoryRichTextBox.Clear(); //TEMP SOL warningText.Text = ""; if (product.name.Equals(GlobalEnums.COLD_WATER)) { column_2.ReadOnly = true; column_5.ReadOnly = true; column_6.ReadOnly = true; column_7.ReadOnly = true; column_8.ReadOnly = true; var water = InfoManager.getItem(GlobalEnums.WATER); editStockGrid.Rows.Add(product.type, product.name, product.price, product.pricePerPack, water.quantityPerPack, water.instock, water.minInstock, water.originalPrice); warningText.Text = string.Format("ไม่สามารถเปลี่ยน '{0}' ได้ กรุณาไปที่ '{5}' ถ้าอยากเปลี่ยนข้อมูลดังต่อไปนี้\n'{4}', '{1}', '{2}', '{3}' (ชั่วคราว)", GlobalEnums.COLUMN_2, GlobalEnums.COLUMN_5, GlobalEnums.COLUMN_6, GlobalEnums.COLUMN_7, GlobalEnums.COLUMN_8, GlobalEnums.WATER); } else { if (product.name.Equals(GlobalEnums.WATER)) { column_2.ReadOnly = true; warningText.Text = string.Format("ไม่สามารถเปลี่ยน '{0}' ได้ (ชั่วคราว)", GlobalEnums.COLUMN_2); } editStockGrid.Rows.Add(product.type, product.name, product.price, product.pricePerPack, product.quantityPerPack, product.instock, product.minInstock, product.originalPrice); } editStockGrid.Rows[0].Selected = false; foreach (ItemHistory itemh in product.getAllItemHistories()) { if (itemh.style == GlobalEnums.HistoryStyle.Edit) { editProductHistoryRichTextBox.AppendText(MessageLibrary.EDIT_ITEM(itemh.date.ToString(), itemh.field, itemh.before, itemh.after)); } else if (itemh.style == GlobalEnums.HistoryStyle.Add) { editProductHistoryRichTextBox.AppendText(MessageLibrary.ADD_ITEM(itemh.date.ToString())); } else if (itemh.style == GlobalEnums.HistoryStyle.Damaged) { editProductHistoryRichTextBox.AppendText(MessageLibrary.DAMAGED_ITEM(itemh.date.ToString(), itemh.field, itemh.before, itemh.after)); editProductHistoryRichTextBox.AppendText("\n"); } else { MessageBox.Show(MessageLibrary.CODE_ERROR_MESSAGE(), MessageLibrary.CODE_ERROR_TITLE(GlobalEnums.CodeError.CE1), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void exportStock_Click(object sender, EventArgs e) { try { var file = FileHelper.WriteCsv(); MessageBox.Show(string.Format(MessageLibrary.EXPORT_SUCCESSFUL.description, file), MessageLibrary.EXPORT_SUCCESSFUL.title, MessageBoxButtons.OK, MessageLibrary.EXPORT_SUCCESSFUL.severity); } catch (Exception exception) { MessageBox.Show(MessageLibrary.EXPORT_ERROR(), MessageLibrary.CODE_ERROR_TITLE(GlobalEnums.CodeError.CE3), MessageBoxButtons.OK, MessageBoxIcon.Error); } }