Ejemplo n.º 1
0
 private void updatePCVTable()
 {
     if (!((hfVoucherID.Value) == null || (hfVoucherID.Value) == ""))
     {
         //String.IsNullOrEmpty(txtRefCode.Text.Trim()) ? "0" : txtRefCode.Text.Trim();
         businessPurpose.Text = String.IsNullOrEmpty(businessPurpose.Text.Trim()) ? "\u00A0" : businessPurpose.Text.Trim();
         PCV_Remark.Text      = String.IsNullOrEmpty(PCV_Remark.Text.Trim()) ? "\u00A0" : PCV_Remark.Text.Trim();
         core_petty_cash_payment_voucher pcvObj = new core_petty_cash_payment_voucher();
         pcvObj.UpdateMethod(@"UPDATE `core_petty_cash_payment_voucher` SET `Cash_Out_Amount` = '" + Convert.ToDouble(hfnetcashOutAmount.Value) + @"', `Business_Purpose` = '" + businessPurpose.Text.Trim().Replace("'", "''") + @"', `Petty_Cash_Voucher_Remark` = '" + PCV_Remark.Text.Trim().Replace("'", "''") + @"', `Edited_Date` = now() WHERE `Id_Petty_Cash_Voucher` = '" + Convert.ToInt32(hfVoucherID.Value) + @"' AND `Is_Active` = '0' AND `Post_Payment` = '1';");
     }
 }
        private void loadNextPCVid()
        {
            core_petty_cash_payment_voucher pcvObj = new core_petty_cash_payment_voucher();
            DataSet ds    = pcvObj.SelectMethod(@"SELECT
COUNT(pcv.Id_Petty_Cash_Voucher) AS count
FROM core_petty_cash_payment_voucher AS pcv;", "core_petty_cash_payment_voucher");
            string  count = ds.Tables[0].Rows[0]["count"].ToString();
            int     x     = (Convert.ToInt32(count) + 1);

            //PCV_Id.Text = x.ToString().PadLeft(4, '0');
            PCV_Id.Text = x.ToString();
        }
        private void insertPCVDetails()
        {
            int payment_Type;

            if (selectedPost.Selected == true)
            {
                payment_Type = 0;
            }
            else if (selectedPre.Selected == true)
            {
                payment_Type = 1;
            }
            else
            {
                payment_Type = 2;
                MessageBox.Show("Error! Please Select a Payment Type");
            }

            if (cmdSubmit.CommandName.ToLower() == "SAVE".ToLower())
            {
                core_petty_cash_payment_voucher         pcvObj = new core_petty_cash_payment_voucher();
                core_petty_cash_payment_voucher_Objects objPCV = new core_petty_cash_payment_voucher_Objects();

                objPCV.Id_Petty_Cash_Voucher  = Convert.ToInt32(PCV_Id.Text);
                objPCV.Id_Petty_Cash_Book     = Convert.ToInt32(ddlPCBName.SelectedValue);
                objPCV.Id_Petty_Cash_Category = Convert.ToInt32(ddlPCCName.SelectedValue);

                double result;
                if (double.TryParse(PCBAvailableBalance.Text, out result))
                {
                    objPCV.Available_Balance_Amount = Convert.ToDouble(PCBAvailableBalance.Text);
                }

                objPCV.Business_Purpose = businessPurpose.Text;
                objPCV.Cash_Out_Amount  = Convert.ToDouble(cashOutAmount.Text);
                objPCV.Received_By      = receivedBy.Text;

                objPCV.Petty_Cash_Voucher_Remark = PCV_Remark.Text;
                objPCV.Created_Date = DateTime.Now;
                objPCV.Edited_Date  = DateTime.Now;
                objPCV.Post_Payment = payment_Type;
                pcvObj.Insert(objPCV);
            }
            if (cmdSubmit.CommandName.ToLower() == "SAVE".ToLower())
            {
                double availableBalance;
                double cashoutamount;
                availableBalance = 0.00;
                cashoutamount    = 0.00;
                availableBalance = Convert.ToDouble(PCBAvailableBalance.Text);
                cashoutamount    = Convert.ToDouble(cashOutAmount.Text.Trim());
                double newAmount = Convert.ToDouble(availableBalance - cashoutamount);

                core_petty_cash_book pcbObj = new core_petty_cash_book();
                pcbObj.UpdateMethod(@"UPDATE `core_petty_cash_book`
                                        SET
                                        `Available_Balance_Amount` = '" + newAmount + @"'                                                                                                                                                            
                                        WHERE `Id_Petty_Cash_Book` = '" + Convert.ToInt32(ddlPCBName.SelectedValue) + @"';");
            }
            if (cmdSubmit.CommandName.ToLower() == "SAVE".ToLower())
            {
                core_ledger_entry         leObj = new core_ledger_entry();
                core_ledger_entry_Objects objLE = new core_ledger_entry_Objects();

                objLE.Id_Petty_Cash_Book     = Convert.ToInt32(ddlPCBName.SelectedValue);
                objLE.Id_Petty_Cash_Category = Convert.ToInt32(ddlPCCName.SelectedValue);
                objLE.Id_Ledger_Account      = Convert.ToInt32(hfIDLedgerAccount.Value);
                objLE.Id_Petty_Cash_Voucher  = Convert.ToInt32(PCV_Id.Text);
                objLE.Business_Purpose       = businessPurpose.Text;

                //double x = Convert.ToDouble(hfIDLedgerAccountBCF.Value);
                //////
                double x = Convert.ToDouble(PCBAvailableBalance.Text);
                //////
                double y = Convert.ToDouble(cashOutAmount.Text);
                objLE.Debit_Amount            = Convert.ToDouble(cashOutAmount.Text);
                objLE.Balance_Carried_Forward = (x - y);
                //double z = (x + y);

                objLE.Created_Date = DateTime.Now;
                objLE.Post_Payment = payment_Type;
                leObj.Insert(objLE);


                //core_ledger_account laObj = new core_ledger_account();
                //laObj.UpdateMethod(@"UPDATE `core_ledger_account`
                //                        SET
                //                        `Balance_Carried_Forward` = '" + z + @"'
                //                        WHERE `Id_Ledger_Account` = '" + Convert.ToInt32(hfIDLedgerAccount.Value) + @"';");
            }

            ScriptManager.RegisterStartupScript(this, GetType(), "insert", "showAlert('success');", true);
            //this.clearFields();
            //loadGrid();
            //Response.Redirect("PettyCashVoucher.aspx", false);
        }
Ejemplo n.º 4
0
        protected void idPrePV_TextChanged(object sender, EventArgs e)
        {
            //if (!IsCallback)
            //{
            //hfVoucherID.Value = idPrePV.Text.Trim();
            core_petty_cash_payment_voucher pcvObj = new core_petty_cash_payment_voucher();
            DataSet ds = pcvObj.SelectMethod(@"SELECT 
pcv.Id_Petty_Cash_Voucher,
pcv.Id_Petty_Cash_Book,
pcb.Petty_Cash_Book_Name,
pcb.Petty_Cash_Book_Code,
pcb.Available_Balance_Amount,
pcv.Id_Petty_Cash_Category,
pcc.Petty_Cash_Category_Name,
pcc.Petty_Cash_Category_Code,
pcc.Id_Ledger_Account,
la.Balance_Carried_Forward,
pcv.Cash_Out_Amount,
pcv.Business_Purpose,
pcv.Received_By,
pcv.Petty_Cash_Voucher_Remark,
pcv.Post_Payment,
pcv.Created_Date,
pcv.Created_User,
pcv.Edited_Date,
pcv.Edited_User
FROM core_petty_cash_payment_voucher AS pcv
INNER JOIN core_petty_cash_book AS pcb ON pcv.Id_Petty_Cash_Book=pcb.Id_Petty_Cash_Book
INNER JOIN core_petty_cash_category AS pcc ON pcv.Id_Petty_Cash_Category=pcc.Id_Petty_Cash_Category
INNER JOIN core_ledger_account AS la ON pcc.Id_Ledger_Account=la.Id_Ledger_Account
WHERE pcv.Id_Petty_Cash_Voucher='" + Convert.ToInt32(hfVoucherID.Value) + @"' AND pcv.Is_Active='0' AND pcv.Post_Payment='1';", "core_petty_cash_payment_voucher");

            try
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    hfPCBID.Value            = ds.Tables[0].Rows[0]["Id_Petty_Cash_Book"].ToString();
                    ddlPCBName.Text          = ds.Tables[0].Rows[0]["Petty_Cash_Book_Name"].ToString();
                    ddlPCBCode.Text          = ds.Tables[0].Rows[0]["Petty_Cash_Book_Code"].ToString();
                    PCBAvailableBalance.Text = ds.Tables[0].Rows[0]["Available_Balance_Amount"].ToString();
                    hfPCCID.Value            = ds.Tables[0].Rows[0]["Id_Petty_Cash_Category"].ToString();
                    ddlPCCName.Text          = ds.Tables[0].Rows[0]["Petty_Cash_Category_Name"].ToString();
                    ddlPCCCode.Text          = ds.Tables[0].Rows[0]["Petty_Cash_Category_Code"].ToString();

                    hfIDLedgerAccount.Value    = ds.Tables[0].Rows[0]["Id_Ledger_Account"].ToString();
                    hfIDLedgerAccountBCF.Value = ds.Tables[0].Rows[0]["Balance_Carried_Forward"].ToString();

                    cashOutAmount.Text   = ds.Tables[0].Rows[0]["Cash_Out_Amount"].ToString();
                    receivedBy.Text      = ds.Tables[0].Rows[0]["Received_By"].ToString();
                    businessPurpose.Text = ds.Tables[0].Rows[0]["Business_Purpose"].ToString();
                    PCV_Remark.Text      = ds.Tables[0].Rows[0]["Petty_Cash_Voucher_Remark"].ToString();
                }
                else
                {
                    ddlPCBName.Text          = "";
                    ddlPCBCode.Text          = "";
                    PCBAvailableBalance.Text = "";
                    ddlPCCName.Text          = "";
                    ddlPCCCode.Text          = "";
                    cashOutAmount.Text       = "";
                    receivedBy.Text          = "";
                    cashInAmount.Text        = "";
                    netcashOutAmount.Text    = "";
                    businessPurpose.Text     = "";
                    PCV_Remark.Text          = "";
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        protected void searchID_Click(object sender, EventArgs e)
        {
            hfVoucherID.Value = idPrePV.Text.Trim();
            core_petty_cash_payment_voucher pcvObj = new core_petty_cash_payment_voucher();
            DataSet ds = pcvObj.SelectMethod(@"SELECT 
pcv.Id_Petty_Cash_Voucher,
pcv.Id_Petty_Cash_Book,
pcb.Petty_Cash_Book_Name,
pcb.Petty_Cash_Book_Code,
pcb.Available_Balance_Amount,
pcv.Id_Petty_Cash_Category,
pcc.Petty_Cash_Category_Name,
pcc.Petty_Cash_Category_Code,
pcc.Id_Ledger_Account,
la.Balance_Carried_Forward,
pcv.Cash_Out_Amount,
pcv.Business_Purpose,
pcv.Received_By,
pcv.Petty_Cash_Voucher_Remark,
pcv.Post_Payment,
pcv.Created_Date,
pcv.Created_User,
pcv.Edited_Date,
pcv.Edited_User
FROM core_petty_cash_payment_voucher AS pcv
INNER JOIN core_petty_cash_book AS pcb ON pcv.Id_Petty_Cash_Book=pcb.Id_Petty_Cash_Book
INNER JOIN core_petty_cash_category AS pcc ON pcv.Id_Petty_Cash_Category=pcc.Id_Petty_Cash_Category
INNER JOIN core_ledger_account AS la ON pcc.Id_Ledger_Account=la.Id_Ledger_Account
WHERE pcv.Id_Petty_Cash_Voucher='" + Convert.ToInt32(hfVoucherID.Value) + @"' AND pcv.Is_Active='0' AND pcv.Post_Payment='1';", "core_petty_cash_payment_voucher");

            if (ds.Tables[0].Rows.Count == 0)
            {
                if (IsPostBack)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "AlertSweet", "alertSweet();", true);
                    ddlPCBName.Text          = "";
                    ddlPCBCode.Text          = "";
                    PCBAvailableBalance.Text = "";
                    ddlPCCName.Text          = "";
                    ddlPCCCode.Text          = "";
                    cashOutAmount.Text       = "";
                    receivedBy.Text          = "";
                    cashInAmount.Text        = "";
                    netcashOutAmount.Text    = "";
                    businessPurpose.Text     = "";
                    PCV_Remark.Text          = "";
                }
            }
            else
            {
                try
                {
                    hfPCBID.Value            = ds.Tables[0].Rows[0]["Id_Petty_Cash_Book"].ToString();
                    ddlPCBName.Text          = ds.Tables[0].Rows[0]["Petty_Cash_Book_Name"].ToString();
                    ddlPCBCode.Text          = ds.Tables[0].Rows[0]["Petty_Cash_Book_Code"].ToString();
                    PCBAvailableBalance.Text = ds.Tables[0].Rows[0]["Available_Balance_Amount"].ToString();
                    hfPCCID.Value            = ds.Tables[0].Rows[0]["Id_Petty_Cash_Category"].ToString();
                    ddlPCCName.Text          = ds.Tables[0].Rows[0]["Petty_Cash_Category_Name"].ToString();
                    ddlPCCCode.Text          = ds.Tables[0].Rows[0]["Petty_Cash_Category_Code"].ToString();

                    hfIDLedgerAccount.Value    = ds.Tables[0].Rows[0]["Id_Ledger_Account"].ToString();
                    hfIDLedgerAccountBCF.Value = ds.Tables[0].Rows[0]["Balance_Carried_Forward"].ToString();

                    cashOutAmount.Text   = ds.Tables[0].Rows[0]["Cash_Out_Amount"].ToString();
                    receivedBy.Text      = ds.Tables[0].Rows[0]["Received_By"].ToString();
                    businessPurpose.Text = ds.Tables[0].Rows[0]["Business_Purpose"].ToString();
                    PCV_Remark.Text      = ds.Tables[0].Rows[0]["Petty_Cash_Voucher_Remark"].ToString();
                }
                catch
                {
                }
            }
        }