private void btnUpdate_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to Update current record ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) ; { BillingDataTypes.BillingDataType _SaveData = new BillingDataTypes.BillingDataType(); string respond = SetDataToPayBill(out _SaveData); if (MyBill.ExistBilling(_SaveData.BillNo, _SaveData.PayToID)) { if (respond == "True") { respond = MyBill.Update(_SaveData); if (respond == "True") { Program.InformationMessage("Record Updated Successfully"); LoadBillList(MyCommon.GetSelectedID(cmbSupplier, true)); } else Program.VerningMessage(respond); } else Program.VerningMessage(respond); } else { Program.VerningMessage("Use Save Button to save new records"); } } }
private string SetDataToPayBill(out BillingDataTypes.BillingDataType _SaveData) { MakeDueDate(); _SaveData = new BillingDataTypes.BillingDataType(); try { _SaveData.AccountID = lblAccnumber.Text; _SaveData.AccPeriod = Program.AccountStatic.CurrentAccPeriod; _SaveData.BillNo = cmbGRN.Text; _SaveData.BillStatus = 0; _SaveData.CompanyID = Program.AccountStatic.CompanyID; _SaveData.Cr =decimal.Parse(lblTotalLKR.Text) ; _SaveData.CurRate = decimal.Parse(lblExchangerate.Text); _SaveData.Description = txtDescription.Text; _SaveData.FCr = decimal.Parse(lblTotalUSD.Text); _SaveData.PayToCatID = 0; //_SaveData.PayToID = int.Parse(MyCommon.GetSelectedID(cmbSupplier, true)); //Edited by manjula _SaveData.PayToID = Convert.ToInt32(supid); _SaveData.TobePayDate = DateTime.Parse(lblDueDate.Text); _SaveData.TrUser = Program.AccountStatic.UserName; _SaveData.TrDate = dtpInvoiceDate.Value; _SaveData.BillDate = dtpBilingDate.Value; _SaveData.PONo = dtpGRNDetals.Rows[0].Cells["PONo"].Value.ToString(); List<BillingDataTypes.BillingDetailsDataType> _SaveDetails = new List<BillingDataTypes.BillingDetailsDataType>(); string respond = SetPayBillDetails(out _SaveDetails); _SaveData.BillingDetails = _SaveDetails; return "True"; } catch (Exception ex) { return ex.Message; } }
private void btnSave_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to Save current record ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) ; { BillingDataTypes.BillingDataType _SaveData = new BillingDataTypes.BillingDataType(); string respond = SetDataToPayBill(out _SaveData); if (!MyBill.ExistBilling(_SaveData.BillNo, _SaveData.PayToID)) { int BillStatus = -1; int SupID = Convert.ToInt32(supid); BillStatus = MyBill.GetBillStatus(cmbGRN.Text, Convert.ToInt32(supid)); if (BillStatus == 0) { if (respond == "True") { respond = MyBill.Save(_SaveData); if (respond == "True") { //Edit by manjula //********************************* update tblmaterials bool res = false; LINKPayment objList; for (int i = 0; i < dtpGRNDetals.Rows.Count; i++) { if (Convert.ToBoolean(dtpGRNDetals.Rows[i].Cells[0].Value) == true) { objList = new LINKPayment(); objList.Status = 9; objList.GRNNo = cmbGRN.SelectedValue.ToString(); objList.MaterialCode = dtpGRNDetals.Rows[i].Cells["MaterialCode"].Value.ToString(); res = objService.SetMaterialStatus(objList); } } Program.InformationMessage("Record saved successfully"); // LoadBillList(MyCommon.GetSelectedID(cmbSupplier, true)); LoadBillList(SupID.ToString()); //Added by manju LINKPayment objLink = new LINKPayment(); objLink.SupName = cmbSupplier.SelectedValue.ToString(); objLink.Status = 0; LoadGRN(objLink); dtpGRNDetals.Columns.Clear(); dtpGRNDetals.DataSource = null; } else Program.VerningMessage(respond); } else Program.VerningMessage(respond); } else { switch (BillStatus) { case 2: Program.VerningMessage("You cannot chage any details of this bill , Tt is already approved" ); break; case 3: Program.VerningMessage("You cannot chage any details of this bill, It is already accounted"); break; default: break; } } } else { Program.VerningMessage("Use Update Button to update details"); } } }
public string GetExistBilling(string BillNo,int SupID, out BillingDataTypes.BillingDataType _ExistData) { _ExistData = new BillingDataTypes.BillingDataType(); MySqlCommand oSqlCommand = new MySqlCommand(); string sqlQuery = "Select " + "BillNo," + "Description," + "AccountID," + "CurRate," + "Cr," + "FCr," + "BillStatus," + "TrRef," + "TrUser," + "TrDate," + "TrTime," + "AccPeriod," + "CompanyID," + "PayToCatID," + "PayToID," + "PayAmount," + "TobePayDate,BillDate" + " from tblpayablebill" + " Where 1=1 " + " and BillNo=@BillNo and PayToID=@PayToID"; oSqlCommand.Parameters.AddWithValue("@BillNo", BillNo); oSqlCommand.Parameters.AddWithValue("@PayToID", SupID); DataRow r = Mycommon.GetDataRowAccount(sqlQuery, oSqlCommand, "Get Exist data Billing"); if (r != null) { try { bool resp = false; _ExistData.BillNo = r["BillNo"].ToString(); _ExistData.Description = r["Description"].ToString(); _ExistData.AccountID = r["AccountID"].ToString(); decimal deCurRate = 0; resp = decimal.TryParse(r["CurRate"].ToString(), out deCurRate); _ExistData.CurRate = deCurRate; decimal deCr = 0; resp = decimal.TryParse(r["Cr"].ToString(), out deCr); _ExistData.Cr = deCr; decimal deFCr = 0; resp = decimal.TryParse(r["FCr"].ToString(), out deFCr); _ExistData.FCr = deFCr; int inBillStatus = 0; resp = int.TryParse(r["BillStatus"].ToString(), out inBillStatus); _ExistData.BillStatus = inBillStatus; _ExistData.TrRef = r["TrRef"].ToString(); _ExistData.TrUser = r["TrUser"].ToString(); DateTime dtTrDate = new DateTime(1900, 1, 1); resp = DateTime.TryParse(r["TrDate"].ToString(), out dtTrDate); if (resp) _ExistData.TrDate = dtTrDate; else _ExistData.TrDate = new DateTime(1900, 1, 1); _ExistData.TrTime = r["TrTime"].ToString(); int inAccPeriod = 0; resp = int.TryParse(r["AccPeriod"].ToString(), out inAccPeriod); _ExistData.AccPeriod = inAccPeriod; int inCompanyID = 0; resp = int.TryParse(r["CompanyID"].ToString(), out inCompanyID); _ExistData.CompanyID = inCompanyID; int inPayToCatID = 0; resp = int.TryParse(r["PayToCatID"].ToString(), out inPayToCatID); _ExistData.PayToCatID = inPayToCatID; int inPayToID = 0; resp = int.TryParse(r["PayToID"].ToString(), out inPayToID); _ExistData.PayToID = inPayToID; decimal dePayAmount = 0; resp = decimal.TryParse(r["PayAmount"].ToString(), out dePayAmount); _ExistData.PayAmount = dePayAmount; DateTime dtTobePayDate = new DateTime(1900, 1, 1); resp = DateTime.TryParse(r["TobePayDate"].ToString(), out dtTobePayDate); if (resp) _ExistData.TobePayDate = dtTobePayDate; else _ExistData.TobePayDate = new DateTime(1900, 1, 1); DateTime dtBillDate = new DateTime(1900, 1, 1); resp = DateTime.TryParse(r["BillDate"].ToString(), out dtBillDate); if (resp) _ExistData.BillDate = dtBillDate; else _ExistData.BillDate = new DateTime(1900, 1, 1); List<BillingDataTypes.BillingDetailsDataType> _ExtList; string respond = GetBillingDetaisList(BillNo, out _ExtList); _ExistData.BillingDetails = _ExtList; return "True"; } catch (Exception ex) { return ex.Message; } } else return "data not found "; }