private void Save()
        {
            PurchaseContractBL       purchaseContractBL = new PurchaseContractBL();
            PurchaseContractDetailBL contractDetailBL   = new PurchaseContractDetailBL();
            var sellerID   = int.Parse(cmbSeller.SelectedValue.ToString());
            var userID     = (cmbUserMaster.SelectedValue.ToString());
            var ApprovedBy = (cmbUserMaster.SelectedValue.ToString());

            if (table == null)
            {
                //var sellerID = int.Parse(((DataRowView)cmbSeller.SelectedItem)[1].ToString());
                purchaseContractId = purchaseContractBL.AddPurchaseContract(dtpPurchaseContractDate.Value, userID, sellerID, ApprovedBy);
            }
            else
            {
                purchaseContractId = (int)table.Rows[0]["PurchaseContractID"];
                purchaseContractBL.UpdatePurchaseContract(dtpPurchaseContractDate.Value, userID, sellerID, purchaseContractId, ApprovedBy);
                contractDetailBL.DeletePurchaseContractDetail(purchaseContractId);
            }

            foreach (DataGridViewRow row in dgvPurchaseContract.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.AddPurchaseContractDetail(weight, price, totalAmount, purchaseContractId, rawmaterialID);
            }
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            PurchaseContractDetailBL contractDetailBL = new PurchaseContractDetailBL();

            PurchaseContractBL productBL = new PurchaseContractBL();

            if (dgvPurchaseContract.SelectedRows.Count > 0)
            {
                var id = (int)dgvPurchaseContract.SelectedRows[0].Cells["PurchaseContractID"].Value;
                contractDetailBL.DeletePurchaseContractDetail(id);
                productBL.DeletePurchaseContract(id);
                LoadPurchaseContract();
            }
        }