private void btn_Order_Click_1(object sender, EventArgs e) { try { listpanel[index = 1].BringToFront(); //Hide other text boxes when first time open txt_ItemType.Visible = false; txt_qty2.Visible = false; btn_add2.Visible = false; btn_remove2.Visible = false; lb_other.Visible = false; lb_Qty2.Visible = false; lb_size.Visible = false; lb_color.Visible = false; cmb_color.Visible = false; cmb_size.Visible = false; //create object of SupplierDBaccess class SupplierDBaccess SA = new SupplierDBaccess(); grid_IdNameItem.DataSource = SA.getSupplierIDNameItem(); PurchaseOrderDBaccess PO = new PurchaseOrderDBaccess(); Grid_PurchaseOrder.DataSource = PO.getAllPurchaseOrders(); grid_IdNameItem.ClearSelection(); txt_POno.Text = PO.GetPurId(); } catch (SqlException) { MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (FormatException) { MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (OutOfMemoryException) { MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_CreOdr_Click(object sender, EventArgs e) { try { if (datagrid_add.Rows.Count == 1) { MetroMessageBox.Show(this, "Add Items Before proceed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { PurchaseOrderDBaccess PO = new PurchaseOrderDBaccess(); PurMaster PM = new PurMaster(); PM.pur_id = txt_POno.Text; PM.sup_id = txt_OsupId.Text; PM.pur_date = Picker_ReqDate.Value.Date; int Status = PO.createPurOrder_master(PM); if (Status == 1) { MetroMessageBox.Show(this, "\n\nOrder Success, And Sending For Approvel", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); txt_OsupId.Text = null; txt_OsupName.Text = null; txt_OsupEmail.Text = null; cmb_ItemType.Text = null; txt_qty.Text = null; txt_qty2.Text = null; txt_ItemType.Text = null; Picker_ReqDate.ResetText(); datagrid_add.Rows.Clear(); datagrid_add.ClearSelection(); grid_IdNameItem.ClearSelection(); lb_SelectSup.Visible = true; txt_POno.Text = PO.GetPurId(); } else { MetroMessageBox.Show(this, "\n\nOrder Fail", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } // PurDetails PD = new PurDetails(); // PD.pd_id = for (int i = 0; i < (datagrid_add.Rows.Count - 1); i++) { PurDetails PD = new PurDetails(); PD.pd_id = PO.GetPDId(); PD.pur_id = txt_POno.Text; PD.pd_Item_type = (datagrid_add.Rows[i].Cells["Item"].Value).ToString(); PD.Size = (datagrid_add.Rows[i].Cells["Size"].Value).ToString(); PD.color = (datagrid_add.Rows[i].Cells["Color"].Value).ToString(); PD.pd_qty = (datagrid_add.Rows[i].Cells["Qty"].Value).ToString(); int status = PO.createPurOrder_details(PD); } PurchaseOrderDBaccess Po = new PurchaseOrderDBaccess(); Grid_PurchaseOrder.DataSource = Po.getAllPurchaseOrders(); } } catch (SqlException) { MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (FormatException) { MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (OutOfMemoryException) { MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } }