private void button2_Click(object sender, EventArgs e) { if (c.isHistoryFormOpen(1) == false) { M_V_history f = new M_V_history(1); Global.background.show_form(f); } }
private void button5_Click(object sender, EventArgs e) { M_V_history f = new M_V_history(3); Global.background.show_form(f); }
public M_V2_dyeingInwardForm(DataRow row, bool isEditable, M_V_history v1_history, string mode) { if (mode == "dyeingInward") { InitializeComponent(); this.edit_form = true; this.v1_history = v1_history; this.c = new DbConnect(); this.batch_no = new List <string>(); this.batch_no.Add(""); this.saveButton.Enabled = false; //Create drop-down Dyeing Company lists var dataSource3 = new List <string>(); DataTable d3 = c.getQC('d'); dataSource3.Add("---Select---"); for (int i = 0; i < d3.Rows.Count; i++) { dataSource3.Add(d3.Rows[i][0].ToString()); } this.dyeingCompanyCB.DataSource = dataSource3; this.dyeingCompanyCB.DisplayMember = "Dyeing_Company_Names"; this.dyeingCompanyCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.dyeingCompanyCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.dyeingCompanyCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down lists var dataSource = new List <string>(); DataTable d = c.getQC('f'); for (int i = 0; i < d.Rows.Count; i++) { dataSource.Add(d.Rows[i][0].ToString()); } this.comboBox3CB.DataSource = dataSource; this.comboBox3CB.DisplayMember = "Financial Year"; this.comboBox3CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox3CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox3CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //DatagridView make dataGridView1.Columns.Add("Sl_No", "Sl_No"); dataGridView1.Columns[0].ReadOnly = true; DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn(); dgvCmb.DataSource = this.batch_no; dgvCmb.HeaderText = "Batch Number"; dataGridView1.Columns.Insert(1, dgvCmb); dataGridView1.Columns.Add("Weight", "Weight"); dataGridView1.Columns.Add("Colour", "Colour"); dataGridView1.Columns.Add("Quality", "Quality"); dataGridView1.Columns.Add("Net Rate", "Net Rate"); dataGridView1.Columns.Add("Slip Number", "Slip Number"); dataGridView1.Columns["Weight"].ReadOnly = true; dataGridView1.Columns["Colour"].ReadOnly = true; dataGridView1.Columns["Quality"].ReadOnly = true; dataGridView1.Columns["Net rate"].ReadOnly = true; dataGridView1.RowCount = 10; //if form is only view-only if (isEditable == false) { this.Text += "(View Only)"; disable_form_edit(); } else { //no option to edit company name and quality this.Text += "(Edit)"; this.inwardDateDTP.Enabled = true; this.dyeingCompanyCB.Enabled = false; this.saveButton.Enabled = true; this.loadBatchButton.Enabled = false; this.dataGridView1.ReadOnly = false; this.comboBox3CB.Enabled = false; } //Fill in required fields this.inputDate.Value = Convert.ToDateTime(row["Date_Of_Input"].ToString()); this.inwardDateDTP.Value = Convert.ToDateTime(row["Inward_Date"].ToString()); this.dyeingCompanyCB.SelectedIndex = this.dyeingCompanyCB.FindStringExact(row["Dyeing_Company_Name"].ToString()); this.comboBox3CB.SelectedIndex = this.comboBox3CB.FindStringExact(row["Batch_Fiscal_Year"].ToString()); if (row["Bill_Date"].ToString() != null && row["Bill_Date"].ToString() != "") { this.billDateDTP.Value = Convert.ToDateTime(row["Bill_Date"].ToString()); } this.voucherID = int.Parse(row["Voucher_ID"].ToString()); string[] batch_nos = c.csvToArray(row["Batch_No_Arr"].ToString()); DataTable batch_data = c.getTableData("Batch", "Batch_No, Net_Weight, Colour, Quality, Dyeing_Rate, Slip_No, Dyeing_In_Date", "Batch_No IN (" + c.removecom(row["Batch_No_Arr"].ToString()) + ") AND Fiscal_Year = '" + row["Batch_Fiscal_Year"].ToString() + "'"); for (int i = 0; i < batch_data.Rows.Count; i++) { string batchno = batch_data.Rows[i]["Batch_No"].ToString(); fetch_data value = new fetch_data(float.Parse(batch_data.Rows[i]["Net_Weight"].ToString()), batch_data.Rows[i]["Colour"].ToString(), batch_data.Rows[i]["Quality"].ToString(), float.Parse(batch_data.Rows[i]["Dyeing_Rate"].ToString()), batch_data.Rows[i]["Slip_No"].ToString(), batch_data.Rows[i]["Dyeing_In_Date"].ToString()); this.batch_fetch_data[batchno] = value; } for (int i = 0; i < batch_nos.Length; i++) { this.batch_no.Add(batch_nos[i]); } this.loadData(row["Dyeing_Company_Name"].ToString(), row["Batch_Fiscal_Year"].ToString()); if (isEditable == false) { dataGridView1.RowCount = batch_nos.Length; } else { dataGridView1.RowCount = batch_nos.Length + 1; } string batch_nos_string = row["Batch_No_Arr"].ToString(); string[] batch_nos_arr = c.csvToArray(row["Batch_No_Arr"].ToString()); DataTable bill_nos = c.getColumnBatchNos("Batch_No, Bill_No, Batch_State", c.removecom(batch_nos_string), this.comboBox3CB.SelectedItem.ToString()); Dictionary <string, Tuple <string, int> > billnos = new Dictionary <string, Tuple <string, int> >(); for (int i = 0; i < bill_nos.Rows.Count; i++) { billnos[bill_nos.Rows[i]["Batch_No"].ToString()] = new Tuple <string, int>(bill_nos.Rows[i]["Bill_No"].ToString(), int.Parse(bill_nos.Rows[i]["Batch_State"].ToString())); } bool flag = true; for (int i = 0; i < batch_nos_arr.Length; i++) { dataGridView1.Rows[i].Cells[1].Value = batch_nos_arr[i]; Tuple <string, int> value = billnos[batch_nos_arr[i]]; string bill_no = value.Item1; if (bill_no != "0") { flag = false; this.batch_editable[batch_nos[i]] = 0; DataGridViewRow r = (DataGridViewRow)dataGridView1.Rows[i]; dataGridView1.Rows[i].ReadOnly = true; r.DefaultCellStyle.BackColor = Color.LightGray; r.DefaultCellStyle.SelectionBackColor = Color.LightGray; } if (value.Item2 == 3) { flag = false; this.batch_editable[batch_nos[i]] = 3; DataGridViewRow r = (DataGridViewRow)dataGridView1.Rows[i]; dataGridView1.Rows[i].ReadOnly = true; r.DefaultCellStyle.BackColor = Color.LightGreen; r.DefaultCellStyle.SelectionBackColor = Color.LightGreen; } else if (value.Item2 == 4) { flag = false; this.batch_editable[batch_nos[i]] = 4; DataGridViewRow r = (DataGridViewRow)dataGridView1.Rows[i]; dataGridView1.Rows[i].ReadOnly = true; r.DefaultCellStyle.BackColor = Color.Orange; r.DefaultCellStyle.SelectionBackColor = Color.Orange; } //pending } this.label5.Text = "Gray: Bill Number Added Green: Batch sent for production Orange: Batch sent for redyeing"; if (isEditable == false) { this.deleteButton.Visible = true; this.deleteButton.Enabled = false; if (flag == true) { this.deleteButton.Enabled = true; } } c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); } if (mode == "addBill") { InitializeComponent(); //common initializations this.Name = "Add Bill Numbers"; this.addBill = true; this.edit_form = true; this.v1_history = v1_history; this.c = new DbConnect(); this.batch_no = new List <string>(); this.batch_no.Add(""); //graphics placement this.billNumberTextboxTB.Visible = true; this.billNumberTextboxTB.Enabled = true; this.billNumberTextboxTB.ReadOnly = false; this.billNumberTextboxTB.TabIndex = 2; this.billNumberTextboxTB.Location = new System.Drawing.Point(24, 94); this.billDateDTP.Visible = true; this.billDateDTP.Location = new System.Drawing.Point(24, 140); this.billDateDTP.Enabled = true; this.billDateDTP.TabIndex = 3; this.inwardDateDTP.Visible = false; this.label1.Visible = false; this.label7.Visible = true; this.label7.Location = new System.Drawing.Point(24, 74); this.label2.Visible = true; this.label2.Location = new System.Drawing.Point(24, 120); this.saveButton.Enabled = false; //DatagridView make dataGridView1.Columns.Add("Sl_No", "Sl_No"); dataGridView1.Columns[0].ReadOnly = true; DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn(); dgvCmb.DataSource = this.batch_no; dgvCmb.HeaderText = "Batch Number"; dataGridView1.Columns.Insert(1, dgvCmb); dataGridView1.Columns.Add("Weight", "Weight"); dataGridView1.Columns.Add("Colour", "Colour"); dataGridView1.Columns.Add("Quality", "Quality"); dataGridView1.Columns.Add("Net Rate", "Net Rate"); dataGridView1.Columns["Weight"].ReadOnly = true; dataGridView1.Columns["Colour"].ReadOnly = true; dataGridView1.Columns["Quality"].ReadOnly = true; dataGridView1.Columns["Net rate"].ReadOnly = true; //Create drop-down Dyeing Company lists var dataSource3 = new List <string>(); DataTable d3 = c.getQC('d'); dataSource3.Add("---Select---"); for (int i = 0; i < d3.Rows.Count; i++) { dataSource3.Add(d3.Rows[i][0].ToString()); } this.dyeingCompanyCB.DataSource = dataSource3; this.dyeingCompanyCB.DisplayMember = "Dyeing_Company_Names"; this.dyeingCompanyCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.dyeingCompanyCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.dyeingCompanyCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down lists var dataSource = new List <string>(); DataTable d = c.getQC('f'); for (int i = 0; i < d.Rows.Count; i++) { dataSource.Add(d.Rows[i][0].ToString()); } this.comboBox3CB.DataSource = dataSource; this.comboBox3CB.DisplayMember = "Financial Year"; this.comboBox3CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox3CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox3CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //if only in view mode if (isEditable == false) { this.Text += "(View Only)"; disable_form_edit(); this.deleteButton.Visible = true; this.deleteButton.Enabled = true; } else { this.Text += "(Edit)"; this.loadBatchButton.Enabled = false; this.saveButton.Enabled = true; this.dyeingCompanyCB.Enabled = false; this.comboBox3CB.Enabled = false; } //Fill in required values this.inputDate.Value = Convert.ToDateTime(row["Date_Of_Input"].ToString()); this.dyeingCompanyCB.SelectedIndex = this.dyeingCompanyCB.FindStringExact(row["Dyeing_Company_Name"].ToString()); this.billNumberTextboxTB.Text = row["Bill_No"].ToString(); this.billDateDTP.Value = Convert.ToDateTime(row["Bill_Date"].ToString()); this.voucherID = int.Parse(row["Voucher_ID"].ToString()); this.comboBox3CB.SelectedIndex = this.comboBox3CB.FindStringExact(row["Batch_Fiscal_Year"].ToString()); //Load previous data string[] batch_nos = c.csvToArray(row["Batch_No_Arr"].ToString()); for (int i = 0; i < batch_nos.Length; i++) { this.batch_no.Add(batch_nos[i]); } //Load data in datagridview dropdown this.loadData(row["Dyeing_Company_Name"].ToString(), row["Batch_Fiscal_Year"].ToString()); DataTable batch_data = c.getTableData("Batch", "Batch_No, Net_Weight, Colour, Quality, Dyeing_Rate, Slip_No, Dyeing_In_Date", "Batch_No IN (" + c.removecom(row["Batch_No_Arr"].ToString()) + ") AND Fiscal_Year = '" + row["Batch_Fiscal_Year"].ToString() + "'"); for (int i = 0; i < batch_data.Rows.Count; i++) { string batchno = batch_data.Rows[i]["Batch_No"].ToString(); fetch_data value = new fetch_data(float.Parse(batch_data.Rows[i]["Net_Weight"].ToString()), batch_data.Rows[i]["Colour"].ToString(), batch_data.Rows[i]["Quality"].ToString(), float.Parse(batch_data.Rows[i]["Dyeing_Rate"].ToString()), batch_data.Rows[i]["Slip_No"].ToString(), batch_data.Rows[i]["Dyeing_In_Date"].ToString()); this.batch_fetch_data[batchno] = value; } if (isEditable == false) { dataGridView1.RowCount = batch_nos.Length; } else { dataGridView1.RowCount = batch_nos.Length + 1; } //Fill data in datagridview for (int i = 0; i < batch_nos.Length; i++) { dataGridView1.Rows[i].Cells[1].Value = batch_nos[i]; } c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); } dataGridView1.ClearSelection(); dataGridView1.CurrentCell = null; }
public M_V3_issueToReDyeingForm(DataRow row, bool isEditable, M_V_history v1_history) { InitializeComponent(); this.edit_form = true; this.v1_history = v1_history; this.all_trays = new DataTable(); this.c = new DbConnect(); this.voucher_id = int.Parse(row["Voucher_ID"].ToString()); //load data this.inputDateDTP.Value = Convert.ToDateTime(row["Date_Of_Input"].ToString()); this.issueDateDTP.Value = Convert.ToDateTime(row["Date_Of_Issue"].ToString()); this.batchNoCB.Items.Add(""); this.batchNoCB.Items.Add(row["Old_Batch_No"].ToString() + " (" + row["Old_Batch_Fiscal_Year"].ToString() + ")"); this.batchNoCB.SelectedIndex = 1; load_batch(); this.redyeing_batch = c.getBatchRow_BatchNo(int.Parse(row["Redyeing_Batch_No"].ToString()), row["Redyeing_Batch_Fiscal_Year"].ToString()); this.non_redyeing_batch = null; float non_redyeing_wt = -1F; string non_redyeing_batch_no = "NA"; if (row["Non_Redyeing_Batch_No"].ToString() != "-1") { non_redyeing_batch = c.getBatchRow_BatchNo(int.Parse(row["Non_Redyeing_Batch_No"].ToString()), row["Old_Batch_Fiscal_Year"].ToString()); non_redyeing_wt = float.Parse(batchWeightTB.Text) - float.Parse(redyeing_batch["Net_Weight"].ToString()); non_redyeing_batch_no = row["Non_Redyeing_Batch_No"].ToString(); } else { this.fullRedyeCK.Checked = true; } this.redyeingBatchNoTB.Text = row["Redyeing_Batch_No"].ToString(); this.nonRedyeingBatchNoTB.Text = non_redyeing_batch_no; this.redyeingBatchWeightTB.Text = float.Parse(redyeing_batch["Net_Weight"].ToString()).ToString("F3"); if (non_redyeing_wt != -1F) { this.nonRedyeingBatchWeightTB.Text = non_redyeing_wt.ToString("F3"); } else { this.nonRedyeingBatchWeightTB.Text = "NA"; } loadButton_Click(null, null); this.redyeingColourCB.SelectedIndex = this.redyeingColourCB.FindStringExact(redyeing_batch["Colour"].ToString()); this.rateTextBoxTB.Text = redyeing_batch["Dyeing_Rate"].ToString(); this.all_trays.Columns.Add("Sl No"); this.all_trays.Columns.Add("Date Of Production"); this.all_trays.Columns.Add("Tray No"); this.all_trays.Columns.Add("Spring"); this.all_trays.Columns.Add("No Of Springs"); this.all_trays.Columns.Add("Tray Tare"); this.all_trays.Columns.Add("Gross Weight"); this.all_trays.Columns.Add("Quality"); this.all_trays.Columns.Add("Company Name"); this.all_trays.Columns.Add("Machine No"); this.all_trays.Columns.Add("Net Weight"); this.all_trays.Columns.Add("Quality Before Twist"); this.all_trays.Columns.Add("Grade"); this.all_trays.Columns.Add("Redyeing"); this.all_trays.Columns.Add("No Of Springs RD"); string[] tray_ids = c.csvToArray(redyeing_batch["Tray_ID_Arr"].ToString()); for (int i = 0; i < tray_ids.Length; i++) { DataRow tray = c.getTrayRow_TrayID(int.Parse(tray_ids[i])); DataRow to_add = this.all_trays.NewRow(); to_add["Sl No"] = i + 1; to_add["Date Of Production"] = tray["Tray_Production_Date"].ToString(); to_add["Tray No"] = tray["Tray_No"].ToString(); to_add["Spring"] = tray["Spring"].ToString(); to_add["No Of Springs"] = tray["Number_of_Springs"].ToString(); to_add["Tray Tare"] = tray["Tray_Tare"].ToString(); to_add["Gross Weight"] = tray["Gross_Weight"].ToString(); to_add["Quality"] = tray["Quality"].ToString(); to_add["Company Name"] = tray["Company_Name"].ToString(); to_add["Machine No"] = tray["Machine_No"].ToString(); to_add["Net Weight"] = tray["Net_Weight"].ToString(); to_add["Net Weight"] = tray["Net_Weight"].ToString(); to_add["Quality Before Twist"] = tray["Quality_Before_Twist"].ToString(); to_add["Grade"] = tray["Grade"].ToString(); to_add["Redyeing"] = tray["Redyeing"].ToString(); to_add["No Of Springs RD"] = tray["No_Of_Springs_RD"].ToString(); this.all_trays.Rows.Add(to_add); } this.dataGridView1.DataSource = this.all_trays; this.dataGridView1.Columns.OfType <DataGridViewColumn>().ToList().ForEach(col => col.Visible = false); this.dataGridView1.Columns["Sl No"].Visible = true; this.dataGridView1.Columns["Sl No"].DisplayIndex = 0; this.dataGridView1.Columns["Sl No"].Width = 80; this.dataGridView1.Columns["Tray No"].Visible = true; this.dataGridView1.Columns["Tray No"].HeaderText = "Tray No"; this.dataGridView1.Columns["Tray No"].DisplayIndex = 2; this.dataGridView1.Columns["Quality"].Visible = true; this.dataGridView1.Columns["Quality"].DisplayIndex = 4; this.dataGridView1.Columns["Quality"].Width = 150; this.dataGridView1.Columns["Net Weight"].Visible = true; this.dataGridView1.Columns["Net Weight"].DisplayIndex = 6; this.dataGridView1.Columns["No Of Springs RD"].Visible = true; this.dataGridView1.Columns["No Of Springs RD"].DisplayIndex = 8; this.dataGridView1.Columns["No Of Springs RD"].HeaderText = "No of redyeing springs"; this.dataGridView1.Columns["No of Springs"].Visible = true; this.dataGridView1.Columns["No of Springs"].DisplayIndex = 10; c.auto_adjust_dgv(this.dataGridView1); this.CellSum(); if (this.dataGridView1.SelectedRows.Count > 0) { this.dataGridView1.SelectedRows[0].Selected = false; } if (int.Parse(redyeing_batch["Batch_State"].ToString()) > 1) { string prefix = "This voucher is not editable/deletable as batch " + this.redyeingBatchNoTB.Text + " has "; int state = int.Parse(redyeing_batch["Batch_State"].ToString()); if (state == 2) { this.label7.Text = prefix + "already come from redyeing"; } else if (state == 3) { if (string.IsNullOrEmpty(redyeing_batch["Date_OF_Production"].ToString())) { this.label7.Text = prefix + "already come from redyeing and is in production"; } else { this.label7.Text = prefix + "already come from redyeing and has been produced"; } } else if (state == 4) { this.label7.Text = prefix + "gone to redyeing again"; } this.label7.ForeColor = Color.Red; this.deleteButton.Visible = true; this.deleteButton.Enabled = false; disable_form_edit(); } if (non_redyeing_batch != null) { if (int.Parse(non_redyeing_batch["Batch_State"].ToString()) > 2) { string prefix = "This voucher is not editable/deletable as batch " + this.nonRedyeingBatchNoTB.Text + " has "; int state = int.Parse(non_redyeing_batch["Batch_State"].ToString()); if (state == 3) { if (string.IsNullOrEmpty(non_redyeing_batch["Date_OF_Production"].ToString())) { this.label7.Text = prefix + "already come from redyeing and is in production"; } else { this.label7.Text = prefix + "already come from redyeing and has been produced"; } } else if (state == 4) { this.label7.Text = prefix + "gone to redyeing again"; } this.label7.ForeColor = Color.Red; this.deleteButton.Visible = true; this.deleteButton.Enabled = false; disable_form_edit(); } } if (isEditable == false) { this.Text += "(View Only)"; this.disable_form_edit(); this.deleteButton.Visible = true; this.deleteButton.Enabled = true; } else { this.Text += "(Edit)"; } }
public M_V5_cartonProductionOpeningForm(DataRow row, bool isEditable, M_V_history v1_history) { InitializeComponent(); this.edit_form = true; this.v1_history = v1_history; this.c = new DbConnect(); this.initialise_comboboxes(); if (isEditable == false) { this.Text += "(View Only)"; this.deleteButton.Visible = true; this.deleteButton.Enabled = true; this.disable_form_edit(); } else { //no option to edit company name and quality Console.WriteLine("Else"); this.Text += "(Edit)"; this.saveButton.Enabled = true; this.dataGridView1.Enabled = true; this.dataGridView1.ReadOnly = false; } this.inputDate.Value = Convert.ToDateTime(row["Date_Of_Input"].ToString()); this.voucher_id = int.Parse(row["Voucher_ID"].ToString()); Dictionary <Tuple <string, string>, DataRow> carton_dict = new Dictionary <Tuple <string, string>, DataRow>(); DataTable carton_info = c.getTableData("Carton_Produced", "*", "Opening_Voucher_ID = " + this.voucher_id + ""); c.printDataTable(carton_info); for (int i = 0; i < carton_info.Rows.Count; i++) { DateTime d = Convert.ToDateTime(carton_info.Rows[i]["Date_Of_Production"].ToString()); carton_dict.Add(new Tuple <string, string>(carton_info.Rows[i]["Carton_No"].ToString(), c.getFinancialYear(d)), carton_info.Rows[i]); } dataGridView1.RowCount = carton_info.Rows.Count + 1; bool flag = false; for (int i = 0; i < carton_info.Rows.Count; i++) { DateTime d = Convert.ToDateTime(carton_info.Rows[i]["Date_Of_Production"].ToString()); Tuple <string, string> temp = new Tuple <string, string>(carton_info.Rows[i]["Carton_No"].ToString(), c.getFinancialYear(d)); DataRow carton_row = carton_dict[temp]; if (carton_row == null) { continue; } string correctformat = Convert.ToDateTime(carton_row["Date_Of_Production"].ToString()).Date.ToString().Substring(0, 10); dataGridView1.Rows[i].Cells["Date_Of_Production"].Value = correctformat; dataGridView1.Rows[i].Cells["Carton_No"].Value = carton_row["Carton_No"].ToString(); dataGridView1.Rows[i].Cells["Grade"].Value = carton_row["Grade"].ToString(); dataGridView1.Rows[i].Cells["Colour"].Value = carton_row["Colour"].ToString(); dataGridView1.Rows[i].Cells["Quality"].Value = carton_row["Quality"].ToString(); dataGridView1.Rows[i].Cells["Net_Weight"].Value = carton_row["Net_Weight"].ToString(); //Sold carton will be coloured green if (carton_row["Carton_State"].ToString() != "1") { flag = true; this.carton_editable[temp] = false; DataGridViewRow r = dataGridView1.Rows[i]; dataGridView1.Rows[i].ReadOnly = true; r.DefaultCellStyle.BackColor = Color.LightGreen; r.DefaultCellStyle.SelectionBackColor = Color.LightGreen; this.deleteButton.Enabled = false; this.label1.Text = "This voucher cannot be deleted as some cartons have alrady been sold"; } } this.cartonweight.Text = CellSum1(6).ToString("F3"); c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); }
public M_VC_cartonSalesForm(DataRow row, bool isEditable, M_V_history v1_history, string form) { InitializeComponent(); this.edit_form = true; this.v1_history = v1_history; this.c = new DbConnect(); this.carton_data = new List <Tuple <string, string> >(); this.tablename = form; //Create frop down type list List <string> dataSource = new List <string>(); dataSource.Add("---Select---"); dataSource.Add("0"); dataSource.Add("1"); this.typeCB.DataSource = dataSource; this.typeCB.DisplayMember = "Type"; this.typeCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.typeCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.typeCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; #region //dropdown //Create drop-down list for quality DataTable d1 = c.getQC('q'); List <string> input_qualities = new List <string>(); input_qualities.Add("---Select---"); for (int i = 0; i < d1.Rows.Count; i++) { if (this.tablename == "Carton") { input_qualities.Add(d1.Rows[i]["Quality_Before_Twist"].ToString()); } else if (this.tablename == "Carton_Produced") { input_qualities.Add(d1.Rows[i]["Quality"].ToString()); } } List <string> norep_quality_list = input_qualities.Distinct().ToList(); this.comboBox1CB.DataSource = norep_quality_list; this.comboBox1CB.DisplayMember = "Quality"; this.comboBox1CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox1CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox1CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Company list var dataSource2 = new List <string>(); if (this.tablename == "Carton_Produced") { dataSource2.Add("Self"); } else if (this.tablename == "Carton") { DataTable d2 = c.getQC('c'); dataSource2.Add("---Select---"); for (int i = 0; i < d2.Rows.Count; i++) { dataSource2.Add(d2.Rows[i][0].ToString()); } } this.comboBox2CB.DataSource = dataSource2; this.comboBox2CB.DisplayMember = "Company_Names"; this.comboBox2CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox2CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox2CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Customers list var dataSource3 = new List <string>(); DataTable d3 = c.getQC('C'); dataSource3.Add("---Select---"); for (int i = 0; i < d3.Rows.Count; i++) { dataSource3.Add(d3.Rows[i][0].ToString()); } this.comboBox3CB.DataSource = dataSource3; this.comboBox3CB.DisplayMember = "Customers"; this.comboBox3CB.DropDownStyle = ComboBoxStyle.DropDown;//Create a drop-down list this.comboBox3CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox3CB.AutoCompleteMode = AutoCompleteMode.Append; var dataSource5 = new List <string>(); if (tablename == "Carton") { this.shadeCB.Items.Add("Gray"); this.shadeCB.SelectedIndex = this.shadeCB.FindStringExact("Gray"); this.shadeCB.Enabled = false; } else { DataTable d5 = c.getQC('l'); dataSource5.Add("---Select---"); for (int i = 0; i < d5.Rows.Count; i++) { dataSource5.Add(d5.Rows[i][0].ToString()); } List <string> final_list1 = dataSource5.Distinct().ToList(); this.shadeCB.DataSource = final_list1; this.shadeCB.DisplayMember = "Colours"; this.shadeCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.shadeCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.shadeCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; } #endregion //dropdown //DatagridView dataGridView1.Columns.Add("Sl_No", "Sl_No"); dataGridView1.Columns[0].ReadOnly = true; DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn(); dgvCmb.HeaderText = "Carton Number"; for (int i = 0; i < this.carton_data.Count; i++) { dgvCmb.Items.Add(this.carton_data[i].Item1 + " (" + this.carton_data[i].Item2 + ")"); } //dgvCmb.DataSource = this.carton_data; dataGridView1.Columns.Insert(1, dgvCmb); dataGridView1.Columns.Add("Weight", "Weight"); dataGridView1.Columns.Add("Shade", "Shade"); dataGridView1.Columns[3].ReadOnly = true; dataGridView1.Columns[2].ReadOnly = true; if (isEditable == false) { this.Text += "(View Only)"; this.saveButton.Enabled = false; this.deleteButton.Visible = true; this.deleteButton.Enabled = true; this.disable_form_edit(); } else { this.Text += "(Edit)"; this.saleDateDTP.Enabled = true; this.comboBox1CB.Enabled = false; this.comboBox2CB.Enabled = false; this.saveButton.Enabled = true; this.dataGridView1.ReadOnly = false; this.saleDONoTB.ReadOnly = true; this.loadCartonButton.Enabled = false; this.typeCB.Enabled = false; } this.saleDateDTP.Value = Convert.ToDateTime(row["Date_Of_Sale"].ToString()); this.typeCB.SelectedIndex = this.typeCB.FindStringExact(row["Type_Of_Sale"].ToString()); if (this.comboBox1CB.FindStringExact(row["Quality"].ToString()) == -1) { norep_quality_list.Add(row["Quality"].ToString()); this.comboBox1CB.DataSource = null; this.comboBox1CB.DataSource = norep_quality_list; } this.comboBox1CB.SelectedIndex = this.comboBox1CB.FindStringExact(row["Quality"].ToString()); if (this.comboBox2CB.FindStringExact(row["Company_Name"].ToString()) == -1) { dataSource2.Add(row["Company_Name"].ToString()); this.comboBox2CB.DataSource = null; this.comboBox2CB.DataSource = dataSource2; } this.comboBox2CB.SelectedIndex = this.comboBox2CB.FindStringExact(row["Company_Name"].ToString()); this.voucher_id = int.Parse(row["Voucher_ID"].ToString()); if (this.comboBox3CB.FindStringExact(row["Customer"].ToString()) == -1) { dataSource3.Add(row["Customer"].ToString()); this.comboBox3CB.DataSource = null; this.comboBox3CB.DataSource = dataSource3; } this.comboBox3CB.SelectedIndex = this.comboBox3CB.FindStringExact(row["Customer"].ToString()); this.saleDONoTB.Text = row["Sale_DO_No"].ToString(); this.rateTextboxTB.Text = row["Sale_Rate"].ToString(); DataTable d = new DataTable(); if (this.tablename == "Carton") { d = c.getTableData(this.tablename, "Carton_No, Net_Weight, Fiscal_Year", "TS_Voucher_ID = " + row["Voucher_ID"].ToString() + " AND Date_Of_Sale IS NOT NULL"); } else { d = c.getTableData(this.tablename, "Carton_No, Net_Weight, Colour, Fiscal_Year", "Sales_Voucher_ID = " + row["Voucher_ID"].ToString() + ""); } dataGridView1.RowCount = d.Rows.Count + 1; for (int i = 0; i < d.Rows.Count; i++) { this.carton_data.Add(new Tuple <string, string>(d.Rows[i]["Carton_No"].ToString(), d.Rows[i]["Fiscal_Year"].ToString())); dgvCmb.Items.Add(d.Rows[i]["Carton_No"].ToString() + " (" + d.Rows[i]["Fiscal_Year"].ToString() + ")"); string colour = "Gray"; if (this.tablename != "Carton") { colour = d.Rows[i]["Colour"].ToString(); } this.carton_fetch_data[new Tuple <string, string>(d.Rows[i]["Carton_No"].ToString(), d.Rows[i]["Fiscal_Year"].ToString())] = new fetch_data(float.Parse(d.Rows[i]["Net_Weight"].ToString()), colour); dataGridView1.Rows[i].Cells[1].Value = d.Rows[i]["Carton_No"].ToString() + " (" + d.Rows[i]["Fiscal_Year"].ToString() + ")"; } this.loadData(row["Quality"].ToString(), row["Company_Name"].ToString()); c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); if (row["Sale_Bill_No"].ToString() != "") { this.label10.Text = "This DO cannot be edited/deleted as its bill as already been made. Delete/Edit its bill first"; this.deleteButton.Enabled = false; this.disable_form_edit(); } }
public M_V1_cartonInwardForm(DataRow row, bool isEditable, M_V_history v1_history) { InitializeComponent(); this.edit_form = true; this.v1_history = v1_history; this.c = new DbConnect(); this.billDateChanged = false; //Initialize datagridview1 dataGridView1.ColumnCount = 3; dataGridView1.Columns[0].HeaderText = "Sl No"; dataGridView1.Columns[1].HeaderText = "Carton No"; dataGridView1.Columns[2].HeaderText = "Weight"; dataGridView1.Columns[0].ReadOnly = true; //Initialize datagridview2 DataTable d1 = c.getQC('q'); Console.WriteLine("Get QC" + d1.Rows.Count); string[] quality_array = c.csvToArray(row["Quality"].ToString()); List <string> no_rep_d1 = new List <string>(); for (int i = 0; i < quality_array.Length; i++) { no_rep_d1.Add(quality_array[i]); } for (int i = 0; i < d1.Rows.Count; i++) { no_rep_d1.Add(d1.Rows[i]["Quality_Before_Twist"].ToString()); } no_rep_d1 = no_rep_d1.Distinct().ToList(); for (int i = 0; i < no_rep_d1.Count; i++) { dataGridView2.Rows.Add(no_rep_d1[i], "", ""); } DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn(); dgvCmb.HeaderText = "Quality"; dgvCmb.Items.Add("---Select---"); for (int i = 0; i < no_rep_d1.Count; i++) { dgvCmb.Items.Add(no_rep_d1[i]); } dgvCmb.Name = "Quality"; dataGridView1.Columns.Insert(1, dgvCmb); dataGridView1.Columns[1].Width = 150; var dataSource2 = new List <string>(); if (isEditable == false) { this.Text += " (View Only)"; this.deleteButton.Visible = true; dataSource2.Add(row["Company_Name"].ToString()); this.comboBox2CB.DataSource = dataSource2; this.comboBox2CB.DisplayMember = "Company_Names"; this.disable_form_edit(); } else { this.Text += " (Edit)"; this.inputDate.Enabled = false; this.billDateDTP.Enabled = true; this.billNumberTextboxTB.Enabled = true; this.comboBox2CB.Enabled = true; this.saveButton.Enabled = true; //Create a drop-down list DataTable d2 = c.getQC('c'); dataSource2.Add("---Select---"); //dataSource2.Add(row["Company_Name"].ToString()); for (int i = 0; i < d2.Rows.Count; i++) { dataSource2.Add(d2.Rows[i][0].ToString()); } this.comboBox2CB.DataSource = dataSource2; if (this.comboBox2CB.FindStringExact(row["Company_Name"].ToString()) == -1) { dataSource2.Add(row["Company_Name"].ToString()); this.comboBox2CB.DataSource = null; this.comboBox2CB.DataSource = dataSource2; } this.comboBox2CB.DisplayMember = "Company_Names"; this.comboBox2CB.SelectedIndex = this.comboBox2CB.FindStringExact(row["Company_Name"].ToString()); } this.comboBox2CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox2CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox2CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.voucher_id = int.Parse(row["Voucher_ID"].ToString()); this.inputDate.Value = Convert.ToDateTime(row["Date_Of_Input"].ToString()); this.billDateDTP.Value = Convert.ToDateTime(row["Date_Of_Billing"].ToString()); this.billNumberTextboxTB.Text = row["Bill_No"].ToString(); this.oldbillno = billNumberTextboxTB.Text; string[] quality = c.csvToArray(row["Quality"].ToString()); string[] quality_arr = c.csvToArray(row["Quality_Arr"].ToString()); string[] carton_no = c.csvToArray(row["Carton_No_Arr"].ToString()); string[] carton_weight_arr = c.csvToArray(row["Carton_Weight_Arr"].ToString()); string[] buy_cost = c.csvToArray(row["Buy_Cost"].ToString()); dataGridView1.RowCount = carton_no.Length + 1; //Load Data into DataGridView2 for (int i = 0; i < quality.Length; i++) { for (int j = 0; j < dataGridView2.Rows.Count; j++) { if (quality[i] == dataGridView2.Rows[j].Cells[0].Value.ToString()) { dataGridView2.Rows[j].Cells[1].Value = buy_cost[i]; } } } bool flag = false; string carton_financial_year = row["Fiscal_Year"].ToString(); //Load Data into datagridview1 for (int i = 0; i < carton_no.Length; i++) { //Set Values dataGridView1.Rows[i].Cells[2].Value = carton_no[i]; dataGridView1.Rows[i].Cells[3].Value = carton_weight_arr[i]; dataGridView1.Rows[i].Cells[1].Value = quality[int.Parse(quality_arr[i])]; //Check if this carton is issued string this_carton_no = dataGridView1.Rows[i].Cells[2].Value.ToString(); string this_quality = dataGridView1.Rows[i].Cells[1].Value.ToString(); string this_company = row["Company_Name"].ToString(); DataTable carton_state_dt = c.runQuery("SELECT Carton_State FROM Carton WHERE Carton_No = '" + this_carton_no + "' AND Fiscal_Year = '" + carton_financial_year + "' AND Quality='" + this_quality + "' AND Company_Name = '" + this_company + "'"); int carton_state = -1; if (carton_state_dt.Rows.Count > 0) { carton_state = int.Parse(carton_state_dt.Rows[0][0].ToString()); } if (carton_state == -1) { c.ErrorBox("Critical Error, Carton Not found: " + this_carton_no, "Error"); } else if (carton_state != 1) { flag = true; this.carton_editable[this_carton_no] = false; DataGridViewRow r = (DataGridViewRow)dataGridView1.Rows[i]; dataGridView1.Rows[i].ReadOnly = true; if (carton_state == 2) { r.DefaultCellStyle.BackColor = Color.LightGray; r.DefaultCellStyle.SelectionBackColor = Color.LightGray; } else if (carton_state == 3) { r.DefaultCellStyle.BackColor = Color.LightGreen; r.DefaultCellStyle.SelectionBackColor = Color.LightGreen; } } } if (flag) { comboBox2CB.Enabled = false; this.deleteButton.Enabled = false; this.label7.Text = "This carton cannot be edited as some cartons have been sold/sent to twist"; } else if (isEditable == false) { //enable delete if none of the cartons are in states 2 or 3 this.deleteButton.Enabled = true; } c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); c.set_dgv_column_sort_state(this.dataGridView2, DataGridViewColumnSortMode.NotSortable); List <int> years = c.getFinancialYearArr(row["Fiscal_Year"].ToString()); this.billDateDTP.MinDate = new DateTime(years[0], 04, 01); this.billDateDTP.MaxDate = new DateTime(years[1], 03, 31); }
public M_V1_cartonTwistForm(DataRow row, bool isEditable, M_V_history v1_history) { InitializeComponent(); this.edit_form = true; this.v1_history = v1_history; this.c = new DbConnect(); this.carton_data = new List <string>(); this.carton_data.Add(""); //Create drop-down lists var dataSource1 = new List <string>(); DataTable d1 = c.getQC('q'); List <string> input_qualities = new List <string>(); input_qualities.Add("---Select---"); for (int i = 0; i < d1.Rows.Count; i++) { input_qualities.Add(d1.Rows[i]["Quality_Before_Twist"].ToString()); } List <string> final_list = input_qualities.Distinct().ToList(); this.comboBox1CB.DataSource = final_list; this.comboBox1CB.DisplayMember = "Quality"; this.comboBox1CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox1CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox1CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; var dataSource2 = new List <string>(); DataTable d2 = c.getQC('c'); dataSource2.Add("---Select---"); for (int i = 0; i < d2.Rows.Count; i++) { dataSource2.Add(d2.Rows[i][0].ToString()); } this.comboBox2CB.DataSource = dataSource2; this.comboBox2CB.DisplayMember = "Company_Names"; this.comboBox2CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox2CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox2CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down lists var dataSource3 = new List <string>(); DataTable d3 = c.getQC('f'); for (int i = 0; i < d3.Rows.Count; i++) { dataSource3.Add(d3.Rows[i][0].ToString()); } this.comboBox3CB.DataSource = dataSource3; this.comboBox3CB.DisplayMember = "Financial Year"; this.comboBox3CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox3CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox3CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //DatagridView dataGridView1.Columns.Add("Sl_No", "Sl_No"); dataGridView1.Columns[0].ReadOnly = true; DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn(); dgvCmb.HeaderText = "Carton Number"; dgvCmb.DataSource = this.carton_data; dataGridView1.Columns.Insert(1, dgvCmb); dataGridView1.Columns[1].Width = 250; dataGridView1.Columns.Add("Weight", "Weight"); dataGridView1.Columns[2].ReadOnly = true; if (isEditable == false) { this.Text += " (View Only)"; this.deleteButton.Visible = true; this.disable_form_edit(); } else { this.Text += " (Edit)"; this.issueDateDTP.Enabled = true; this.comboBox1CB.Enabled = false; this.comboBox2CB.Enabled = false; this.comboBox3CB.Enabled = false; this.saveButton.Enabled = true; this.dataGridView1.ReadOnly = false; this.loadCartonButton.Enabled = false; } this.issueDateDTP.Value = Convert.ToDateTime(row["Date_Of_Issue"].ToString()); if (this.comboBox1CB.FindStringExact(row["Quality"].ToString()) == -1) { dataSource1.Add(row["Quality"].ToString()); this.comboBox1CB.DataSource = null; this.comboBox1CB.DataSource = dataSource1; } this.comboBox1CB.SelectedIndex = this.comboBox1CB.FindStringExact(row["Quality"].ToString()); if (this.comboBox2CB.FindStringExact(row["Company_Name"].ToString()) == -1) { dataSource2.Add(row["Company_Name"].ToString()); this.comboBox2CB.DataSource = null; this.comboBox2CB.DataSource = dataSource2; } this.comboBox2CB.SelectedIndex = this.comboBox2CB.FindStringExact(row["Company_Name"].ToString()); this.comboBox3CB.SelectedIndex = this.comboBox3CB.FindStringExact(row["Carton_Fiscal_Year"].ToString()); this.voucher_id = int.Parse(row["Voucher_ID"].ToString()); string[] carton_no = c.csvToArray(row["Carton_No_Arr"].ToString()); DataTable carton_data = c.getTableData("Carton", "Carton_No, Net_Weight", "Carton_No IN (" + c.removecom(row["Carton_No_Arr"].ToString()) + ") AND Fiscal_Year='" + row["Carton_Fiscal_Year"].ToString() + "' AND Company_Name = '" + row["Company_Name"].ToString() + "' AND Quality = '" + row["Quality"].ToString() + "'"); for (int i = 0; i < carton_no.Length; i++) { this.carton_data.Add(carton_no[i]); } for (int i = 0; i < carton_data.Rows.Count; i++) { this.carton_fetch_data[carton_data.Rows[i]["Carton_No"].ToString()] = float.Parse(carton_data.Rows[i]["Net_Weight"].ToString()); } this.loadData(row["Quality"].ToString(), row["Company_Name"].ToString(), row["Carton_Fiscal_Year"].ToString()); dataGridView1.RowCount = carton_no.Length + 1; for (int i = 0; i < carton_no.Length; i++) { dataGridView1.Rows[i].Cells[1].Value = carton_no[i]; } c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); }
public M_V2_trayInputForm(DataRow row, bool isEditable, M_V_history v1_history) { InitializeComponent(); this.v1_history = v1_history; this.c = new DbConnect(); this.edit_form = isEditable; //Create drop-down quality list var dataSource1 = new List <string>(); this.d1 = c.getQC('q'); dataSource1.Add("---Select---"); for (int i = 0; i < d1.Rows.Count; i++) { dataSource1.Add(d1.Rows[i][0].ToString()); } this.qualityCB.DataSource = dataSource1; this.qualityCB.DisplayMember = "Quality"; this.qualityCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.qualityCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.qualityCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Company list var dataSource2 = new List <string>(); DataTable d2 = c.getQC('c'); for (int i = 0; i < d2.Rows.Count; i++) { dataSource2.Add(d2.Rows[i][0].ToString()); } this.companyNameCB.DataSource = dataSource2; this.companyNameCB.DisplayMember = "Company_Names"; this.companyNameCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.companyNameCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.companyNameCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Spring list spring_table = new DataTable(); var dataSource3 = new List <string>(); this.spring_table = c.getQC('s'); for (int i = 0; i < spring_table.Rows.Count; i++) { dataSource3.Add(spring_table.Rows[i][0].ToString()); } this.springCB.DataSource = dataSource3; this.springCB.DisplayMember = "Spring"; this.springCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.springCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.springCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; var dataSource4 = new List <string>(); DataTable dm = c.getTableData("Machine_No", "*", ""); dataSource4.Add("---Select---"); for (int i = 0; i < dm.Rows.Count; i++) { dataSource4.Add(dm.Rows[i]["Machine_No"].ToString()); } this.machineNoCB.DataSource = dataSource4; this.machineNoCB.DisplayMember = "Machine_Number"; this.machineNoCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.machineNoCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.machineNoCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Spring list var dataSource5 = new List <string>(); dataSource5.Add("---Select---"); dataSource5.Add("1st"); dataSource5.Add("PQ"); dataSource5.Add("CLQ"); this.gradeCB.DataSource = dataSource5; this.gradeCB.DisplayMember = "Grade"; this.gradeCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.gradeCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.gradeCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.tray_id = int.Parse(row["Tray_ID"].ToString()); this.state = c.getTrayState(this.tray_id); if (this.state == -1) { label1.Text = "Tray Has Been Processed \nTray Number may now be in\nuse in another Voucher"; label1.ForeColor = Color.Red; this.deleteButton.Visible = true; this.deleteButton.Enabled = false; isEditable = false; } else if (this.state == 2) { label1.Text = "Voucher is not editable \nTray has been sent for dyeing"; label1.ForeColor = Color.Red; this.deleteButton.Visible = true; this.deleteButton.Enabled = false; isEditable = false; } if (isEditable == false) { this.Text += "(View Only)"; this.deleteButton.Visible = true; this.disable_form_edit(); } else { this.Text += "(Edit)"; this.dateTimePickerDTP.Enabled = true; this.qualityCB.Enabled = true; this.companyNameCB.Enabled = true; this.springCB.Enabled = true; this.addButton.Enabled = true; this.trayNumberTB.Enabled = true; this.numberOfSpringsTB.Enabled = true; this.traytareTB.Enabled = true; this.grossWeightTB.Enabled = true; this.machineNoCB.Enabled = true; this.gradeCB.Enabled = true; } this.dateTimePicker1.Value = Convert.ToDateTime(row["Input_Date"].ToString()); this.dateTimePickerDTP.Value = Convert.ToDateTime(row["Tray_Production_Date"].ToString()); this.trayNumberTB.Text = row["Tray_No"].ToString(); this.springCB.SelectedIndex = this.springCB.FindStringExact(row["Spring"].ToString()); this.qualityCB.SelectedIndex = this.qualityCB.FindStringExact(row["Quality"].ToString()); this.companyNameCB.SelectedIndex = this.companyNameCB.FindStringExact(row["Company_Name"].ToString()); this.machineNoCB.SelectedIndex = this.machineNoCB.FindStringExact(row["Machine_No"].ToString()); this.voucher_id = int.Parse(row["Voucher_ID"].ToString()); this.numberOfSpringsTB.Text = row["Number_Of_Springs"].ToString(); this.traytareTB.Text = row["Tray_Tare"].ToString(); this.grossWeightTB.Text = row["Gross_Weight"].ToString(); this.qualityBeforeTwistTB.Text = row["Quality_Before_Twist"].ToString(); this.old_tray_no = row["Tray_No"].ToString(); this.gradeCB.SelectedIndex = this.gradeCB.FindStringExact(row["Grade"].ToString()); }
public M_V2_dyeingIssueForm(DataRow row, bool isEditable, M_V_history v1_history) { InitializeComponent(); this.edit_form = true; this.v1_history = v1_history; this.c = new DbConnect(); this.tray_no = new List <string>(); this.tray_no.Add(""); this.saveButton.Enabled = false; //Create drop-down Quality lists var dataSource1 = new List <string>(); DataTable d1 = c.getQC('q'); dataSource1.Add("---Select---"); for (int i = 0; i < d1.Rows.Count; i++) { dataSource1.Add(d1.Rows[i][0].ToString()); } this.comboBox1CB.DataSource = dataSource1; this.comboBox1CB.DisplayMember = "Quality"; this.comboBox1CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox1CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox1CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Company lists var dataSource2 = new List <string>(); DataTable d2 = c.getQC('c'); dataSource2.Add("---Select---"); for (int i = 0; i < d2.Rows.Count; i++) { dataSource2.Add(d2.Rows[i][0].ToString()); } this.comboBox2CB.DataSource = dataSource2; this.comboBox2CB.DisplayMember = "Company_Names"; this.comboBox2CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox2CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox2CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Dyeing Company lists var dataSource3 = new List <string>(); DataTable d3 = c.getQC('d'); dataSource3.Add("---Select---"); for (int i = 0; i < d3.Rows.Count; i++) { dataSource3.Add(d3.Rows[i][0].ToString()); } this.comboBox3CB.DataSource = dataSource3; this.comboBox3CB.DisplayMember = "Dyeing_Company_Names"; this.comboBox3CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox3CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox3CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Colour lists var dataSource4 = new List <string>(); DataTable d4 = c.getQC('l'); dataSource4.Add("---Select---"); for (int i = 0; i < d4.Rows.Count; i++) { dataSource4.Add(d4.Rows[i][0].ToString()); } List <string> final_list = dataSource4.Distinct().ToList(); this.comboBox4CB.DataSource = final_list; this.comboBox4CB.DisplayMember = "Colours"; this.comboBox4CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox4CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox4CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //DatagridView dataGridView1.Columns.Add("Sl_No", "Sl_No"); dataGridView1.Columns[0].ReadOnly = true; DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn(); dgvCmb.DataSource = this.tray_no; dgvCmb.HeaderText = "Tray Number"; dataGridView1.Columns.Insert(1, dgvCmb); dataGridView1.Columns[1].Width = 250; dataGridView1.Columns.Add("Weight", "Weight"); dataGridView1.Columns["Weight"].ReadOnly = true; dataGridView1.Columns.Add("Machine_Number", "Machine Number"); dataGridView1.Columns["Machine_Number"].ReadOnly = true; dataGridView1.Columns.Add("Grade", "Grade"); dataGridView1.Columns[4].ReadOnly = true; dataGridView1.RowCount = 10; bool invalid_edit = false; //make isEditable false if batch is in future states this.batch_state = c.getBatchState(int.Parse(row["Batch_No"].ToString()), row["Batch_Fiscal_Year"].ToString()); if (batch_state == 2) { dynamicEditableLabel.Text = "This voucher is not editable as the Batch has been recieved from dyeing"; invalid_edit = true; } else if (batch_state == 3) { dynamicEditableLabel.Text = "This voucher is not editable as the Batch has been packed"; invalid_edit = true; } else if (batch_state == 4) { dynamicEditableLabel.Text = "This voucher is not editable as the Batch has been split for redyeing"; invalid_edit = true; } if (isEditable == false) { if (invalid_edit == true) { this.deleteButton.Enabled = false; } else { this.deleteButton.Enabled = true; } this.deleteButton.Visible = true; } if (isEditable == false || invalid_edit == true) { this.Text += "(View Only)"; this.disable_form_edit(); } else { //no option to edit company name and quality this.Text += "(Edit)"; this.comboBox1CB.Enabled = false; this.comboBox2CB.Enabled = false; this.comboBox3CB.Enabled = true; this.comboBox4CB.Enabled = true; this.saveButton.Enabled = true; this.loadCartonButton.Enabled = false; this.dataGridView1.ReadOnly = false; } this.inputDateDTP.Value = Convert.ToDateTime(row["Date_Of_Input"].ToString()); this.issueDateDTP.Value = Convert.ToDateTime(row["Date_Of_Issue"].ToString()); this.comboBox1CB.SelectedIndex = this.comboBox1CB.FindStringExact(row["Quality"].ToString()); this.comboBox2CB.SelectedIndex = this.comboBox2CB.FindStringExact(row["Company_Name"].ToString()); this.comboBox3CB.SelectedIndex = this.comboBox3CB.FindStringExact(row["Dyeing_Company_Name"].ToString()); this.comboBox4CB.SelectedIndex = this.comboBox4CB.FindStringExact(row["Colour"].ToString()); this.rateTextBoxTB.Text = row["Dyeing_Rate"].ToString(); this.old_fiscal_year = row["Batch_Fiscal_Year"].ToString(); batchNumberTextboxTB.Text = row["Batch_No"].ToString(); this.voucherID = int.Parse(row["Voucher_ID"].ToString()); this.tray_no_this = c.csvToArray(row["Tray_No_Arr"].ToString()); this.tray_id_this = c.csvToArray(row["Tray_ID_Arr"].ToString()); for (int i = 0; i < tray_no_this.Length; i++) { this.tray_no.Add(tray_no_this[i]); } DataTable tray_data = c.getTrayDataBothTables("Tray_No, Net_Weight, Machine_No, Grade, Tray_ID", "Tray_ID IN (" + c.removecom(row["Tray_ID_Arr"].ToString()) + ")"); for (int i = 0; i < tray_data.Rows.Count; i++) { this.tray_fetch_data[tray_data.Rows[i]["Tray_No"].ToString()] = new fetch_data(float.Parse(tray_data.Rows[i]["Net_Weight"].ToString()), tray_data.Rows[i]["Machine_No"].ToString(), tray_data.Rows[i]["Grade"].ToString(), int.Parse(tray_data.Rows[i]["Tray_ID"].ToString())); } this.loadData(row["Quality"].ToString(), row["Company_Name"].ToString()); dataGridView1.RowCount = tray_no_this.Length + 1; for (int i = 0; i < tray_no_this.Length; i++) { dataGridView1.Rows[i].Cells[1].Value = tray_no_this[i]; } string voucher_fiscal_year = c.getFinancialYear(this.issueDateDTP.Value); string today_fiscal_year = c.getFinancialYear(DateTime.Now); List <int> years = c.getFinancialYearArr(voucher_fiscal_year); if (today_fiscal_year == voucher_fiscal_year) { this.issueDateDTP.MinDate = new DateTime(years[0], 04, 01); this.issueDateDTP.MaxDate = DateTime.Now; } else { this.issueDateDTP.MinDate = new DateTime(years[0], 04, 01); this.issueDateDTP.MaxDate = new DateTime(years[1], 03, 31); } c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); }
public M_VC_addBill(DataRow row, bool isEditable, M_V_history v1_history, string form) { InitializeComponent(); //common initializations this.Name = "Add Bill"; this.tablename = form; this.edit_form = true; this.v1_history = v1_history; this.c = new DbConnect(); this.do_no = new List <string>(); this.do_no.Add(""); //Create frop down type list List <string> dataSource = new List <string>(); dataSource.Add("---Select---"); dataSource.Add("0"); dataSource.Add("1"); this.typeCB.DataSource = dataSource; this.typeCB.DisplayMember = "Type"; this.typeCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.typeCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.typeCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down lists var dataSource1 = new List <string>(); DataTable d = c.getQC('f'); for (int i = 0; i < d.Rows.Count; i++) { dataSource1.Add(d.Rows[i][0].ToString()); } this.financialYearCB.DataSource = dataSource1; this.financialYearCB.DisplayMember = "Financial Year"; this.financialYearCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.financialYearCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.financialYearCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Quality lists DataTable d1 = c.getQC('q'); List <string> input_qualities = new List <string>(); input_qualities.Add("---Select---"); for (int i = 0; i < d1.Rows.Count; i++) { if (this.tablename == "Carton") { input_qualities.Add(d1.Rows[i]["Quality_Before_Twist"].ToString()); } else if (this.tablename == "Carton_Produced") { input_qualities.Add(d1.Rows[i]["Quality"].ToString()); } } List <string> norep_quality_list = input_qualities.Distinct().ToList(); this.qualityCB.DataSource = norep_quality_list; this.qualityCB.DisplayMember = "Quality"; this.qualityCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.qualityCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.qualityCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Customers list var dataSource4 = new List <string>(); DataTable d4 = c.getQC('C'); dataSource4.Add("---Select---"); for (int i = 0; i < d4.Rows.Count; i++) { dataSource4.Add(d4.Rows[i][0].ToString()); } this.billCustomerNameCB.DataSource = dataSource4; this.billCustomerNameCB.DisplayMember = "Customers"; this.billCustomerNameCB.DropDownStyle = ComboBoxStyle.DropDown;//Create a drop-down list this.billCustomerNameCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.billCustomerNameCB.AutoCompleteMode = AutoCompleteMode.Append; //DatagridView make dataGridView1.Columns.Add("Sl_No", "Sl_No"); dataGridView1.Columns[0].ReadOnly = true; DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn(); //List<string> final_list = this.do_no.Distinct().ToList(); dgvCmb.HeaderText = "DO Number"; dataGridView1.Columns.Insert(1, dgvCmb); dataGridView1.Columns.Add("DO Weight", "DO Weight"); dataGridView1.Columns.Add("DO Amount", "DO Amount"); dataGridView1.Columns[2].ReadOnly = true; dataGridView1.Columns[3].ReadOnly = true; //if only in view mode if (isEditable == false) { this.Text += "(View Only)"; this.deleteButton.Visible = true; this.deleteButton.Enabled = true; this.disable_form_edit(); } else { this.Text += "(Edit)"; this.typeCB.Enabled = false; this.financialYearCB.Enabled = false; this.qualityCB.Enabled = false; this.loadDOButton.Enabled = false; this.saveButton.Enabled = true; } //Fill in required values this.inputDate.Value = Convert.ToDateTime(row["Date_Of_Input"].ToString()); this.billDateDTP.Value = Convert.ToDateTime(row["Sale_Bill_Date"].ToString()); this.qualityCB.SelectedIndex = this.qualityCB.FindStringExact(row["Quality"].ToString()); this.billNumberTextboxTB.Text = row["Sale_Bill_No"].ToString(); this.voucher_id = int.Parse(row["Voucher_ID"].ToString()); this.financialYearCB.SelectedIndex = this.financialYearCB.FindStringExact(row["DO_Fiscal_Year"].ToString()); this.typeCB.SelectedIndex = this.typeCB.FindStringExact(row["Type_Of_Sale"].ToString()); this.billWeightTB.Text = row["Sale_Bill_Weight"].ToString(); this.billAmountTB.Text = row["Sale_Bill_Amount"].ToString(); this.netDOWeightTB.Text = row["Sale_Bill_Weight_Calc"].ToString(); this.netDOAmountTB.Text = row["Sale_Bill_Amount_Calc"].ToString(); if (typeCB.Text == "0") { this.label13.Visible = true; this.billCustomerNameCB.Visible = true; this.billCustomerNameCB.TabIndex = 8; this.billCustomerNameCB.TabStop = true; this.billCustomerNameCB.SelectedIndex = this.billCustomerNameCB.FindStringExact(row["Bill_Customer"].ToString()); } //Load data in datagridview dropdown this.loadData(row["Quality"].ToString(), row["DO_Fiscal_Year"].ToString(), row["Type_Of_Sale"].ToString()); //Load previous data string[] do_nos = c.csvToArray(row["DO_No_Arr"].ToString()); for (int i = 0; i < do_nos.Length; i++) { this.do_no.Add(do_nos[i]); } dataGridView1.RowCount = do_nos.Length + 1; //Fill data in datagridview for (int i = 0; i < do_nos.Length; i++) { dataGridView1.Rows[i].Cells[1].Value = do_nos[i]; } dgvCmb.DataSource = this.do_no; //if (typeCB.Text == "1") //{ // this.billDateDTP.MinDate = this.inputDate.Value.Date.AddDays(-2); // this.billDateDTP.MaxDate = this.inputDate.Value.Date.AddDays(2); //} c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); }