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)
                {
                int VoucherStatus = MyReceipt.GetReceiptStatus(txtRcptNumber.Text);
                switch (VoucherStatus)
                    {

                     case 3:
                        Program.InformationMessage("Already Accounted, cannot chage");
                        break;
                    default:
                        if (MyReceipt.ExistReceipt(txtRcptNumber.Text))
                            {
                            REceiptTypes.ReceiptDataType _SaveHeader = new REceiptTypes.ReceiptDataType();
                            string respond = "";
                            string Rcpt = "";
                            string SelItem = MyCommon.GetSelectedID(cmbPayFor, true);
                            if (SelItem == "5")
                                {
                                MyAccount.SaveotherPayee(cmbPayTo.Text, lblAddress.Text);
                                }
                            respond = SetHeaderDatatoClass(out _SaveHeader);
                            if (respond == "True")
                                {

                                respond = MyReceipt.Update (_SaveHeader);
                                if (respond == "True")
                                    {
                                  
                                    LoadExtPaymentList();
                                    MessageBox.Show("Data Saved Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                else
                                    {
                                    txtRcptNumber.Text = "";
                                    Program.VerningMessage(respond);

                                    }
                                }

                            }
                        else
                            {
                            Program.VerningMessage("Use Update Button");
                            }
                        break;
                    }
                }
            }
Beispiel #2
0
 public string GetExistReceipt(string ReceiptID, out REceiptTypes.ReceiptDataType _ExistData)
 {
     _ExistData = new REceiptTypes.ReceiptDataType();
     MySqlCommand oSqlCommand = new MySqlCommand();
     string sqlQuery = "Select "
   + "ReceiptID,"
   + "ReceiptMethod,"
   + "Description,"
   + "AccountID,"
   + "CurRate,"
   + "Dr,"
   + "FDr,"
   + "ReceiptStatus,"
   + "TrRef,"
   + "TrUser,"
   + "TrDate,"
   + "TrTime,"
   + "ChequeNumber,"
   + "AccPeriod,"
   + "CompanyID,"
   + "RcptFromCatID,"
   + "RcptFromName,"
   + "RcptActualDate,"
   + "ApproveBy,"
   + "ApproveDate,"
   + "ApproveTime,"
   + "AcountedBy,"
   + "AccountDate,"
   + "AccountedTime"
   + " from tblreceipt"
   + " Where 1=1 "
         + " and ReceiptID=@ReceiptID";
     oSqlCommand.Parameters.AddWithValue("@ReceiptID", ReceiptID);
     DataRow r = Mycommon.GetDataRowAccount(sqlQuery, oSqlCommand,  "Get Exist data Receipt");
     if (r != null)
     {
         try
         {
             bool resp = false;
             _ExistData.ReceiptID = r["ReceiptID"].ToString();
             int inReceiptMethod = 0;
             resp = int.TryParse(r["ReceiptMethod"].ToString(), out inReceiptMethod);
             _ExistData.ReceiptMethod = inReceiptMethod;
             _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 deDr = 0;
             resp = decimal.TryParse(r["Dr"].ToString(), out deDr);
             _ExistData.Dr = deDr;
             decimal deFDr = 0;
             resp = decimal.TryParse(r["FDr"].ToString(), out deFDr);
             _ExistData.FDr = deFDr;
             int inReceiptStatus = 0;
             resp = int.TryParse(r["ReceiptStatus"].ToString(), out inReceiptStatus);
             _ExistData.ReceiptStatus = inReceiptStatus;
             _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();
             _ExistData.ChequeNumber = r["ChequeNumber"].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 inRcptFromCatID = 0;
             resp = int.TryParse(r["RcptFromCatID"].ToString(), out inRcptFromCatID);
             _ExistData.RcptFromCatID = inRcptFromCatID;
             _ExistData.RcptFromName = r["RcptFromName"].ToString();
             DateTime dtRcptActualDate = new DateTime(1900, 1, 1);
             resp = DateTime.TryParse(r["RcptActualDate"].ToString(), out dtRcptActualDate);
             if (resp)
                 _ExistData.RcptActualDate = dtRcptActualDate;
             else
                 _ExistData.RcptActualDate = new DateTime(1900, 1, 1);
             _ExistData.ApproveBy = r["ApproveBy"].ToString();
             DateTime dtApproveDate = new DateTime(1900, 1, 1);
             resp = DateTime.TryParse(r["ApproveDate"].ToString(), out dtApproveDate);
             if (resp)
                 _ExistData.ApproveDate = dtApproveDate;
             else
                 _ExistData.ApproveDate = new DateTime(1900, 1, 1);
             _ExistData.ApproveTime = r["ApproveTime"].ToString();
             _ExistData.AcountedBy = r["AcountedBy"].ToString();
             DateTime dtAccountDate = new DateTime(1900, 1, 1);
             resp = DateTime.TryParse(r["AccountDate"].ToString(), out dtAccountDate);
             if (resp)
                 _ExistData.AccountDate = dtAccountDate;
             else
                 _ExistData.AccountDate = new DateTime(1900, 1, 1);
             _ExistData.AccountedTime = r["AccountedTime"].ToString();
          List <REceiptTypes.ReceiptDetailsDataType> _ExtDetails=new List<REceiptTypes.ReceiptDetailsDataType>();
             string rsp = GetReceiptList(ReceiptID, out _ExtDetails);
             _ExistData.ReceiptList = _ExtDetails;
             return "True";
         }
         catch (Exception ex)
         {
             return ex.Message;
         }
     }
     else
         return "data not found ";
 }
        private string SetHeaderDatatoClass(out REceiptTypes.ReceiptDataType   _SaveHeader)
            {
            _SaveHeader = new REceiptTypes.ReceiptDataType();
            try
                {
                _SaveHeader.AccountID = MyCommon.GetSelectedID(cmbFromAcc, true);
                _SaveHeader.ChequeNumber = cmbMethodObg.Text;
                _SaveHeader.Dr = decimal.Parse(txtToalAmountLKR.Text);
                _SaveHeader.CurRate = decimal.Parse(txtExRate.Text);
                _SaveHeader.Description = txtfromMemo.Text;
                _SaveHeader.FDr = decimal.Parse(txtToalAmountFCR.Text);
                _SaveHeader.ReceiptID  = txtRcptNumber.Text;
                _SaveHeader.ReceiptMethod  = int.Parse(MyCommon.GetSelectedID(cmbPayMethod, true));
                _SaveHeader.ReceiptStatus  = 0;
                _SaveHeader.TrUser = Program.AccountStatic.UserName;
                _SaveHeader.CompanyID = Program.AccountStatic.CompanyID;
                _SaveHeader.AccPeriod = Program.AccountStatic.CurrentAccPeriod;
                _SaveHeader.RcptFromCatID  = int.Parse(MyCommon.GetSelectedID(cmbPayFor, true));
                _SaveHeader.RcptFromName  = cmbPayTo.Text;
                _SaveHeader.RcptActualDate  = dtpPVNDate.Value;
                List<REceiptTypes.ReceiptDetailsDataType> _SaveDetailList;
                string respond = SetDetailDataToClass(out _SaveDetailList);
                _SaveHeader.ReceiptList = _SaveDetailList;
                return "True";

                }
            catch (Exception ex)
                {

                return ex.Message;
                }
            }