private void txtSupplierRef_Leave(object sender, EventArgs e)
        {
            txtSupplierRef.Text = clsSupplier.ChangeCase(txtSupplierRef.Text, 1);
            clsSupplier warehouse = new clsSupplier()
            {
                SupplierRef = txtSupplierRef.Text.TrimEnd()
            };

            txtSupplierName.Text = warehouse.GetSupplierName();
        }
        private void TxtSupplierRef_Leave(object sender, EventArgs e)
        {
            TxtSupplierRef.Text = clsUtils.ChangeCase(TxtSupplierRef.Text, 1);
            clsSupplier supplier = new clsSupplier()
            {
                SupplierRef = TxtSupplierRef.Text.TrimEnd()
            };

            TxtSupplierName.Text = supplier.GetSupplierName();
        }
        private void LoadData()
        {
            TxtTotalNet.Clear();
            TxtCommission.Clear();
            TxtDeliveryCharges.Clear();
            TxtTotalOrderPrice.Clear();
            DgvItems.Columns.Clear();
            int PurchaseID;

            PurchaseID = Convert.ToInt32(TxtOrderID.Text.TrimEnd());
            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = clsUtils.GetConnString(1);
                conn.Open();
                DataTable      PurchaseHead        = new DataTable();
                SqlDataAdapter PurchaseDataAdapter = new SqlDataAdapter();
                using (SqlCommand SelectCmd = new SqlCommand())
                {
                    SelectCmd.Connection  = conn;
                    SelectCmd.CommandText = "SELECT * from tblPurchaseOrders WHERE PurchaseOrderID = @PurchaseOrderID";
                    SelectCmd.Parameters.AddWithValue("@PurchaseOrderID", PurchaseID);
                    PurchaseDataAdapter.SelectCommand = SelectCmd;
                    PurchaseDataAdapter.Fill(PurchaseHead);
                }
                TxtOurRef.Text      = PurchaseHead.Rows[0][1].ToString();
                TxtSupplierRef.Text = PurchaseHead.Rows[0][2].ToString();
                clsSupplier supplier = new clsSupplier();
                supplier.SupplierRef = TxtSupplierRef.Text;
                TxtSupplierName.Text = supplier.GetSupplierName();
                clsWarehouse warehouse = new clsWarehouse(LoggedUser);
                TxtWarehouseRef.Text    = PurchaseHead.Rows[0][3].ToString();
                warehouse.WarehouseRef  = TxtWarehouseRef.Text;
                TxtWarehouseName.Text   = warehouse.GetWarehouseName();
                CboSeasonName.Text      = PurchaseHead.Rows[0][4].ToString();
                TxtTotalGarments.Text   = PurchaseHead.Rows[0][5].ToString();
                TxtTotalBoxes.Text      = PurchaseHead.Rows[0][6].ToString();
                TxtTotalLooseItems.Text = PurchaseHead.Rows[0][7].ToString();
                TxtTotalNet.Text        = PurchaseHead.Rows[0][8].ToString();
                TxtDeliveryCharges.Text = PurchaseHead.Rows[0][9].ToString();
                TxtCommission.Text      = PurchaseHead.Rows[0][10].ToString();
                TxtVATAmount.Text       = PurchaseHead.Rows[0][11].ToString();
                TxtTotalOrderPrice.Text = PurchaseHead.Rows[0][12].ToString();


                dateTimePicker1.Value = Convert.ToDateTime(PurchaseHead.Rows[0][13].ToString());
                //deliveryType not on form [14]
                TxtNotes.Text = PurchaseHead.Rows[0][15].ToString();
                TxtSuppliersInvoiceNumber.Text = PurchaseHead.Rows[0][16].ToString();
                TxtShipperName.Text            = PurchaseHead.Rows[0][17].ToString();
                TxtShipperInvoiceNumber.Text   = PurchaseHead.Rows[0][18].ToString();
            }
            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = clsUtils.GetConnString(1);
                conn.Open();
                DataTable      PurchaseLines   = new DataTable();
                SqlDataAdapter PurchaseLinesDA = new SqlDataAdapter();
                using (SqlCommand SelectCmd = new SqlCommand())
                {
                    SelectCmd.Connection  = conn;
                    SelectCmd.CommandText = "SELECT StockCode,DeliveredQtyGarments,DeliveredQtyBoxes,DeliveredQtyHangers,LineAmount FROM tblPurchaseOrderLines WHERE PurchaseOrderID = @PurchaseOrderID";
                    SelectCmd.Parameters.AddWithValue("@PurchaseOrderID", PurchaseID);
                    PurchaseLinesDA.SelectCommand = SelectCmd;
                    PurchaseLinesDA.Fill(PurchaseLines);
                }
                DgvItems.DataSource          = PurchaseLines;
                DgvItems.AutoGenerateColumns = true;
                DgvItems.CellBorderStyle     = DataGridViewCellBorderStyle.None;
                DgvItems.BackgroundColor     = Color.LightCoral;
                DgvItems.DefaultCellStyle.SelectionBackColor     = Color.Red;
                DgvItems.DefaultCellStyle.SelectionForeColor     = Color.Yellow;
                DgvItems.ColumnHeadersDefaultCellStyle.BackColor = Color.Black;
                DgvItems.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
                DgvItems.DefaultCellStyle.WrapMode                 = DataGridViewTriState.True;
                DgvItems.SelectionMode                             = DataGridViewSelectionMode.FullRowSelect;
                DgvItems.AllowUserToResizeColumns                  = false;
                DgvItems.AutoSizeColumnsMode                       = DataGridViewAutoSizeColumnsMode.Fill;
                DgvItems.RowsDefaultCellStyle.BackColor            = Color.LightSkyBlue;
                DgvItems.AlternatingRowsDefaultCellStyle.BackColor = Color.LightYellow;
                DgvItems.Columns[0].HeaderText                     = "Stock Code";
                DgvItems.Columns[1].HeaderText                     = "Garments";
                DgvItems.Columns[2].HeaderText                     = "Boxes";
                DgvItems.Columns[3].HeaderText                     = "Hangers";
                DgvItems.Columns[4].HeaderText                     = "Value";
                DgvItems.Columns[4].DefaultCellStyle.Format        = "C2";
            }
        }
        private void LoadData()
        {
            int WarehouseReturnID = Convert.ToInt32(txtReturnID.Text.TrimEnd());

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = clsUtils.GetConnString(1);
                conn.Open();
                DataTable      WarehouseReturnHead        = new DataTable();
                SqlDataAdapter WarehouseReturnDataAdapter = new SqlDataAdapter();
                using (SqlCommand SelectCmd = new SqlCommand())
                {
                    SelectCmd.Connection  = conn;
                    SelectCmd.CommandText = "SELECT * from tblWarehouseReturns WHERE WarehouseReturnsID = @WarehouseReturnsID";
                    SelectCmd.Parameters.AddWithValue("@WarehouseReturnsID", WarehouseReturnID);
                    WarehouseReturnDataAdapter.SelectCommand = SelectCmd;
                    WarehouseReturnDataAdapter.Fill(WarehouseReturnHead);
                }
                txtWarehouseRef.Text = WarehouseReturnHead.Rows[0][1].ToString();
                clsWarehouse warehouse = new clsWarehouse(0);
                warehouse.WarehouseRef = txtWarehouseRef.Text;
                txtWarehouseName.Text  = warehouse.GetWarehouseName();
                txtSupplierRef.Text    = WarehouseReturnHead.Rows[0][2].ToString();
                clsSupplier supplier = new clsSupplier();
                supplier.SupplierRef = txtSupplierRef.Text.TrimEnd();
                txtSupplierName.Text = supplier.GetSupplierName();
                txtReference.Text    = WarehouseReturnHead.Rows[0][3].ToString();
                txtTotalItems.Text   = WarehouseReturnHead.Rows[0][4].ToString();
                DtpDate.Value        = Convert.ToDateTime(WarehouseReturnHead.Rows[0][5]);
                oldDate = DtpDate.Value;
            }
            DgvRecords.Columns.Clear();
            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = clsUtils.GetConnString(1);
                conn.Open();
                DataTable      WarehouseReturnLine            = new DataTable();
                SqlDataAdapter WarehouseReturnLineDataAdapter = new SqlDataAdapter();
                using (SqlCommand SelectCmd = new SqlCommand())
                {
                    SelectCmd.Connection  = conn;
                    SelectCmd.CommandText = "SELECT StockCode,Qty from tblWarehouseReturnLines WHERE WarehouseReturnID = @WarehouseReturnID";
                    SelectCmd.Parameters.AddWithValue("@WarehouseReturnID", WarehouseReturnID);
                    WarehouseReturnLineDataAdapter.SelectCommand = SelectCmd;
                    WarehouseReturnLineDataAdapter.Fill(WarehouseReturnLine);
                    DgvRecords.DataSource          = WarehouseReturnLine;
                    DgvRecords.AutoGenerateColumns = true;
                    DgvRecords.CellBorderStyle     = DataGridViewCellBorderStyle.None;
                    DgvRecords.BackgroundColor     = Color.LightCoral;
                    DgvRecords.DefaultCellStyle.SelectionBackColor     = Color.Red;
                    DgvRecords.DefaultCellStyle.SelectionForeColor     = Color.Yellow;
                    DgvRecords.ColumnHeadersDefaultCellStyle.BackColor = Color.Black;
                    DgvRecords.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
                    DgvRecords.DefaultCellStyle.WrapMode                 = DataGridViewTriState.True;
                    DgvRecords.SelectionMode                             = DataGridViewSelectionMode.FullRowSelect;
                    DgvRecords.AllowUserToResizeColumns                  = false;
                    DgvRecords.AutoSizeColumnsMode                       = DataGridViewAutoSizeColumnsMode.Fill;
                    DgvRecords.RowsDefaultCellStyle.BackColor            = Color.LightSkyBlue;
                    DgvRecords.AlternatingRowsDefaultCellStyle.BackColor = Color.LightYellow;
                    DgvRecords.Columns[0].HeaderText                     = "Stock Code";
                    DgvRecords.Columns[1].HeaderText                     = "Qty";
                }
                Totals();
            }
        }