Пример #1
0
        private void Usp_BindPurchaseGrid(int PurchaseProductID)
        {
            DataTable dt = new DataTable();
            BLPurchase objBL = new BLPurchase();
            dt = objBL.BindFullGrid(PurchaseProductID);
            if (dt.Rows.Count > 0)
            {
                dgvPurchase.DataSource = dt;
                dgvPurchase.Refresh();
                dgvPurchase.Show();
                dgvPurchase.Columns["ProductID"].Visible = false;
                dgvPurchase.AllowUserToAddRows = false;
                dgvPurchase.AllowUserToDeleteRows = false;

            }
        }
Пример #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validate())
                {
                    BLPurchase obj_Purchase= new BLPurchase();
                    #region------------------temp------------------------
                    //if (btnAdd.Text == "Save")
                    //{
                    //    int PurchaseProductID = 0;
                    //    //int WarehouseID = Convert.ToInt32(cbWarehouse.SelectedValue);
                    //    //int SupplierID = Convert.ToInt32(cbSupplierName.SelectedValue);
                    //    //string ProductType = cbProductType.Text;
                    //    int ProductID = Convert.ToInt32(cbProduct.SelectedValue);
                    //    double PurchaseRate = Convert.ToDouble(txtPurchasePrice.Text);
                    //    //int SellingPrice = Convert.ToInt32(txtSellingPrice.Text);
                    //    string BatchNo = txtBatchNo.Text;
                    //    double Quantity = Convert.ToDouble(txtQuantity.Text);
                    //    DateTime ExpiryDate = Convert.ToDateTime(dtpExpiryDate.Text);
                    //    //string ModeofPayment = txtModeofPayment.Text;

                    //    //DateTime PurchaseDate = Convert.ToDateTime(dtpPurchaseDate.Text);
                    //    //string IsActive = "Yes";
                    //    //string IsDelete = "No";
                    //    string result = obj_Purchase.saveRecord(PurchaseProductID, ProductID, PurchaseRate, BatchNo, Quantity, ExpiryDate);
                    //    if (result == "1")
                    //    {
                    //        MessageBox.Show(" Record Added Successfully...");
                    //        Usp_BindPurchaseGrid();
                    //        clearRecords();
                    //        cbSupplierName.Enabled = false;
                    //        cbWarehouse.Enabled = false;
                    //        dtpPurchaseDate.Enabled = false;

                    //    }
                    //    else
                    //    {
                    //        //MessageBox.Show("This Supplier Name is Already Exits");

                    //    }
                    //    clearRecords();
                    //}
                    //else
                    //{
                    #endregion
                    int UpdatedByUserID = 1;
                    if (temp == 1)
                    {
                        int PurchaseProductID = 0;
                        int WarehouseID = Convert.ToInt32(cbWarehouse.SelectedValue);
                        int SupplierID = Convert.ToInt32(cbSupplierName.SelectedValue);

                        string PurchaseDate = Convert.ToString(dtpPurchaseDate.Text);
                        string ExpiryDate = Convert.ToString(dtpExpiryDate.Text);
                        string IsActive = "Yes";
                        string IsDelete = "No";
                        string ModeOfPayment = txtModeofPayment.Text;
                        string SupplierRecieptNo = txtSupplierRecieptNo.Text;

                        string result = obj_Purchase.SaveWarehouseProduct(PurchaseProductID, WarehouseID, SupplierID, UpdatedByUserID, PurchaseDate, IsActive, IsDelete, ModeOfPayment, SupplierRecieptNo);

                        rst = Convert.ToInt32(result);
                        btnSave.Enabled = true;
                        cbWarehouse.Enabled = false;
                        txtModeofPayment.Enabled = false;
                        cbSupplierName.Enabled = false;
                        txtSupplierRecieptNo.Enabled = false;
                        dtpPurchaseDate.Enabled = false;
                        temp = 2;
                    }
                         int  NewPurchaseProductID = rst;
                        int ProductID = Convert.ToInt32(cbProduct.SelectedValue);
                        double PurchasePrice = Convert.ToDouble(txtPurchasePrice.Text);
                        double SellingPrice = Convert.ToDouble(txtSellingPrice.Text);
                        string BatchNo = txtBatchNo.Text;
                        double Quantity = Convert.ToDouble(txtQuantity.Text);
                        //double Total = Convert.ToDouble(txtTotal.Text);
                        string dt1 = Convert.ToString(dtpPurchaseDate.Text);
                        string dt2 = Convert.ToString(dtpExpiryDate.Text);
                        //DateTime  = Convert.ToDateTime(dtpExpiryDate.Text);
                        //string ModeofPayment = txtModeofPayment.Text;
                        //int UpdatedByUserID = 1;
                        //DateTime PurchaseDate = Convert.ToDateTime(dtpPurchaseDate.Text);
                        //string IsActive = "Yes";
                        //string IsDelete = "No";
                        string Result = obj_Purchase.saveRecord(NewPurchaseProductID, ProductID, PurchasePrice, BatchNo, Quantity, dt2,SellingPrice,UpdatedByUserID);
                        //if (Result == "1")
                       // {
                            //MessageBox.Show("Record Updated successfully...");
                        Total = Total + (Quantity * PurchasePrice);
                        txtTotal.Text = Total.ToString();
                        Usp_BindPurchaseGrid(NewPurchaseProductID);
                            clearRecords();
                            lblPurchase.Text = "";
                    //txtModeofPayment.Text="";
                    //txtSupplierRecieptNo.Text = "";
                        //}
                        //btnAdd.Text = "Save";
                    //}
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }