Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SalesContractBL       salesContractBL  = new SalesContractBL();
            SalesContractDetailBL contractDetailBL = new SalesContractDetailBL();
            var buyerID    = int.Parse(cmbBuyer.SelectedValue.ToString());
            var userID     = (cmbUserMaster.SelectedValue.ToString());
            var ApprovedBy = (cmbUserMaster.SelectedValue.ToString());

            //int salesContractId = 0;
            if (table == null)
            {
                //var sellerID = int.Parse(((DataRowView)cmbSeller.SelectedItem)[1].ToString());
                salesContractId = salesContractBL.AddSalesContract(dtpSalesContractDate.Value, userID, buyerID, ApprovedBy);
            }
            else
            {
                salesContractId = (int)table.Rows[0]["SalesContractID"];
                salesContractBL.UpdateSalesContract(dtpSalesContractDate.Value, userID, buyerID, salesContractId, ApprovedBy);
                contractDetailBL.DeleteSalesContractDetail(salesContractId);
            }

            foreach (DataGridViewRow row in dgvDetailSalesContract.Rows)
            //for (int i=0;i< dgvPurchaseContract.Rows.Count;i++)
            {
                //var row = dgvPurchaseContract.Rows[i];
                var weight        = Decimal.Parse(row.Cells["Weight"].Value.ToString());
                var price         = Decimal.Parse(row.Cells["Price"].Value.ToString());
                var totalAmount   = Decimal.Parse(row.Cells["TotalAmount"].Value.ToString());
                var rawmaterialID = int.Parse(row.Cells["Product"].Value.ToString());
                contractDetailBL.AddSalesContractDetail(weight, price, totalAmount, salesContractId, rawmaterialID);
            }

            MessageBox.Show("Save Successfully!");
        }
Example #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            SalesContractDetailBL contractDetailBL = new SalesContractDetailBL();

            SalesContractBL productBL = new SalesContractBL();

            if (dgvSalesContract.SelectedRows.Count > 0)
            {
                var id = (int)dgvSalesContract.SelectedRows[0].Cells["SalesContractID"].Value;
                contractDetailBL.DeleteSalesContractDetail(id);
                productBL.DeleteSalesContract(id);
                LoadSalesContract();
            }
        }
Example #3
0
        public void SetSalesContract(int ID)
        {
            SalesContractBL salesContractBL = new SalesContractBL();

            table = salesContractBL.GetSalesContractByID(ID);
            dtpSalesContractDate.Value  = DateTime.Parse(table.Rows[0]["SaleContractDate"].ToString());
            cmbUserMaster.SelectedValue = table.Rows[0]["PreparedBy"].ToString();
            cmbBuyer.SelectedValue      = table.Rows[0]["BuyerID"];
            //txtCompanyName.Text = table.Rows[0]["CompanyName"].ToString();

            SalesContractDetailBL contractDetailBL = new SalesContractDetailBL();
            var tbl = contractDetailBL.GetSalesContractDetailByID((int)table.Rows[0]["SalesContractID"]);

            //foreach (var row in tbl.Rows)
            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                var index = dgvDetailSalesContract.Rows.Add();
                dgvDetailSalesContract.Rows[index].Cells["Weight"].Value      = tbl.Rows[i]["Weight"];
                dgvDetailSalesContract.Rows[index].Cells["Price"].Value       = tbl.Rows[i]["Price"];
                dgvDetailSalesContract.Rows[index].Cells["TotalAmount"].Value = tbl.Rows[i]["TotalAmount"];
                dgvDetailSalesContract.Rows[index].Cells["Product"].Value     = tbl.Rows[i]["ProductID"];
            }
        }