예제 #1
0
        public RecieptVoucherModel CreateVoucherForDomesticInvoice(RecieptVoucherModel Voucher)
        {
            Entity Receipt = new Entity(CrmEntityName);

            Receipt["new_indv"]           = new EntityReference(CrmEntityNamesMapping.IndividualContract, new Guid(Voucher.contractid));
            Receipt["new_paymenttype"]    = new OptionSetValue((int)ReceiptVoucher_PaymentTypes.BankTransfer);
            Receipt["new_pointofreciept"] = new OptionSetValue((int)ReceiptVoucher_ReceiptFrom.IndividualCustomer);
            Receipt["new_refrencenumber"] = Voucher.paymentcode;


            Receipt["new_amount"]             = new Money(decimal.Parse(Voucher.amount));
            Receipt["new_vaterate"]           = decimal.Parse(Voucher.vatrate);
            Receipt["new_vatamount"]          = decimal.Parse(Voucher.amount) * decimal.Parse(Voucher.vatrate);
            Receipt["new_totalamountwithvat"] = new Money((decimal.Parse(Voucher.amount) * decimal.Parse(Voucher.vatrate)) + decimal.Parse(Voucher.amount));

            Receipt["new_receiptdate"] = DateTime.ParseExact(Voucher.datatime, "dd/MM/yyyy", null);
            Receipt["new_contactid"]   = new EntityReference(CrmEntityNamesMapping.Contact, new Guid(Voucher.Customerid));
            Receipt["new_source"]      = new OptionSetValue(Voucher.who);

            if (Voucher.who == 2)
            {
                Receipt["new_note"] = String.Format(" تم انشاء السند عن طريق تحويل بنكى- دفع اونلاين- من الويب بورتال لفاتورة أفراد رقم {0} وللعقد رقم {1} ", Voucher.InvoiceNumber, Voucher.Contractnumber);
            }
            else
            {
                Receipt["new_note"] = String.Format(" تم انشاء السند عن طريق تحويل بنكى –دفع اونلاين-  من تطبيق الجوال لفاتورة أفراد رقم {0} وللعقد رقم {1} ", Voucher.InvoiceNumber, Voucher.Contractnumber);
            }

            Guid Id = GlobalCode.Service.Create(Receipt);

            Voucher.Voucherid = Id.ToString();
            return(Voucher);
        }
예제 #2
0
 public HttpResponseMessage AddRecieptVoucherForDomesticInvoice(RecieptVoucherModel Voucher)
 {
     using (var recieptVoucherMgr = new RecieptVoucherManager())
     {
         recieptVoucherMgr.CreateVoucherForDomesticInvoice(Voucher);
         Manager.PayDomesticInvoice(Voucher.InvoiceId);
         return(OkResponse <RecieptVoucherModel>(Voucher));
     }
 }
예제 #3
0
        public List <RecieptVoucherModel> GetRecieptbyId(long id)
        {
            List <RecieptVoucherModel> lstReciept = new List <RecieptVoucherModel>();
            RecieptVoucherModel        objReciept;
            StringBuilder SbQuery = new StringBuilder();

            SbQuery.AppendLine("SELECT p.*,m.ACC_Name FROM reciept_voucher_master as p");
            SbQuery.AppendLine("left join accountmaster as m on p.LedgerId=m.Ac_Id");
            SbQuery.AppendLine("WHERE `Reciept_Id`=" + id);
            System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(SbQuery.ToString(), _dbHelper.GetConnObject());

            while (dr.Read())
            {
                objReciept = new RecieptVoucherModel();

                objReciept.RV_Id          = DataFormat.GetInteger(dr["Reciept_ID"]);
                objReciept.Voucher_Series = dr["Series"].ToString();
                objReciept.RV_Date        = DataFormat.GetDateTime(dr["Reciept_Date"]);
                objReciept.Voucher_Number = DataFormat.GetInteger(dr["VoucherNo"]);
                objReciept.Type           = dr["Type"].ToString();
                objReciept.LedgerId       = Convert.ToInt64(dr["LedgerId"].ToString());
                objReciept.Party          = dr["ACC_Name"].ToString();
                objReciept.PDCDate        = Convert.ToDateTime(dr["PDC_Date"]);
                objReciept.LongNarration  = dr["LongNarration"].ToString();
                objReciept.TotalCreditAmt = Convert.ToDecimal(dr["TotalCreditAmt"]);
                objReciept.TotalDebitAmt  = Convert.ToDecimal(dr["TotalDebitAmt"]);

                //SELECT Payment Voucher Details

                string itemQuery = "SELECT * FROM `Reciept_Voucher_Details` WHERE `Reciept_Id`=" + objReciept.RV_Id;
                System.Data.IDataReader drAcc = _dbHelper.ExecuteDataReader(itemQuery, _dbHelper.GetConnObject());

                objReciept.RecieptAccountModel = new List <AccountModel>();
                AccountModel objAcc;

                while (drAcc.Read())
                {
                    objAcc = new AccountModel();

                    objAcc.AC_Id     = DataFormat.GetInteger(drAcc["AC_Id"]);
                    objAcc.ParentId  = DataFormat.GetInteger(drAcc["Reciept_Id"]);
                    objAcc.DC        = drAcc["DC"].ToString();
                    objAcc.Account   = drAcc["Account"].ToString();
                    objAcc.Debit     = Convert.ToDecimal(drAcc["Debit"]);
                    objAcc.Credit    = Convert.ToDecimal(drAcc["Credit"]);
                    objAcc.Narration = drAcc["Narration"].ToString();

                    objReciept.RecieptAccountModel.Add(objAcc);
                }

                lstReciept.Add(objReciept);
            }
            return(lstReciept);
        }
예제 #4
0
        public List <RecieptVoucherModel> GetRecieptbyId(int id)
        {
            List <RecieptVoucherModel> lstReciept = new List <RecieptVoucherModel>();
            RecieptVoucherModel        objReciept;

            string Query = "SELECT * FROM Reciept_Voucher WHERE Reciept_Id=" + id;

            System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject());

            while (dr.Read())
            {
                objReciept = new RecieptVoucherModel();

                objReciept.RV_Id          = DataFormat.GetInteger(dr["Reciept_ID"]);
                objReciept.Voucher_Series = dr["Series"].ToString();
                objReciept.RV_Date        = DataFormat.GetDateTime(dr["Reciept_Date"]);
                objReciept.Voucher_Number = DataFormat.GetInteger(dr["VoucherNo"]);
                objReciept.Type           = dr["Type"].ToString();
                if (dr["PDC_Date"].ToString() != "")
                {
                    objReciept.PDCDate = Convert.ToDateTime(dr["PDC_Date"]);
                }

                //SELECT Payment Voucher Accounts

                string itemQuery = "SELECT * FROM Reciept_Voucher_Accounts WHERE Reciept_Id=" + objReciept.RV_Id;
                System.Data.IDataReader drAcc = _dbHelper.ExecuteDataReader(itemQuery, _dbHelper.GetConnObject());

                objReciept.RecieptAccountModel = new List <AccountModel>();
                AccountModel objAcc;

                while (drAcc.Read())
                {
                    objAcc = new AccountModel();

                    objAcc.AC_Id     = DataFormat.GetInteger(drAcc["AC_Id"]);
                    objAcc.ParentId  = DataFormat.GetInteger(drAcc["Reciept_Id"]);
                    objAcc.DC        = drAcc["DC"].ToString();
                    objAcc.Account   = drAcc["Account"].ToString();
                    objAcc.Debit     = Convert.ToDecimal(drAcc["Debit"]);
                    objAcc.Credit    = Convert.ToDecimal(drAcc["Credit"]);
                    objAcc.Narration = drAcc["Narration"].ToString();

                    objReciept.RecieptAccountModel.Add(objAcc);
                }

                lstReciept.Add(objReciept);
            }
            return(lstReciept);
        }
예제 #5
0
        public HttpResponseMessage AddRecieptVoucher(RecieptVoucherModel Voucher)
        {
            Entity Receipt = new Entity("new_receiptvoucher");

            Receipt["new_contracthourid"]     = new EntityReference("new_hindvcontract", new Guid(Voucher.contractid));
            Receipt["new_paymenttype"]        = new OptionSetValue(2);
            Receipt["new_refrencenumber"]     = Voucher.paymentcode;
            Receipt["new_amount"]             = new Money(decimal.Parse(Voucher.amount));
            Receipt["new_vaterate"]           = decimal.Parse(Voucher.vatrate);
            Receipt["new_vatamount"]          = decimal.Parse(Voucher.amount) * decimal.Parse(Voucher.vatrate);
            Receipt["new_totalamountwithvat"] = new Money((decimal.Parse(Voucher.amount) * decimal.Parse(Voucher.vatrate)) + decimal.Parse(Voucher.amount));

            Receipt["new_receiptdate"]    = DateTime.ParseExact(Voucher.datatime, "dd/MM/yyyy", null);
            Receipt["new_contactid"]      = new EntityReference("contact", new Guid(Voucher.Customerid));
            Receipt["new_pointofreciept"] = new OptionSetValue(4);
            Receipt["new_source"]         = new OptionSetValue(Voucher.who);

            if (Voucher.who == 2)
            {
                Receipt["new_note"] = "تم انشاء السند عن طريق تحويل بنكى من الويب بورتال  للعقد رقم " + Voucher.Contractnumber;
            }
            else
            {
                Receipt["new_note"] = "تم انشاء السند عن طريق تحويل بنكى من  تطبيق الجوال  للعقد رقم  " + Voucher.Contractnumber;
            }



            Guid Id = GlobalCode.Service.Create(Receipt);

            Entity Contract = GlobalCode.Service.Retrieve("new_hindvcontract", new Guid(Voucher.contractid), new ColumnSet(false));

            Contract["new_ispaid"]          = true;
            Contract["new_contractconfirm"] = true;
            Contract["statuscode"]          = new OptionSetValue(100000009);

            GlobalCode.Service.Update(Contract);

            Voucher.Voucherid = Id.ToString();
            return(OkResponse(Voucher));
        }
예제 #6
0
        public bool SaveRecieptVoucher(RecieptVoucherModel objReciept)
        {
            string Query   = string.Empty;
            bool   isSaved = true;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@VoucherNumber", objReciept.Voucher_Number));
                paramCollection.Add(new DBParameter("@Series", objReciept.Voucher_Series));
                paramCollection.Add(new DBParameter("@RecieptDate", objReciept.RV_Date, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@Type", objReciept.Type));
                paramCollection.Add(new DBParameter("@LedgerId", objReciept.LedgerId));
                paramCollection.Add(new DBParameter("@PDCDate", objReciept.PDCDate, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@LongNarration", objReciept.LongNarration));
                paramCollection.Add(new DBParameter("@TotalCreditAmount", objReciept.TotalCreditAmt, System.Data.DbType.Decimal));
                paramCollection.Add(new DBParameter("@TotalDebitAmount", objReciept.TotalDebitAmt, System.Data.DbType.Decimal));

                paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@ModifiedBy", ""));
                paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now, System.Data.DbType.DateTime));

                System.Data.IDataReader dr =
                    _dbHelper.ExecuteDataReader("spInsertRecieptMaster", _dbHelper.GetConnObject(), paramCollection, System.Data.CommandType.StoredProcedure);

                int id = 0;
                dr.Read();
                id = Convert.ToInt32(dr[0]);
                SaveRecieptAccounts(objReciept.RecieptAccountModel, id);
            }
            catch (Exception ex)
            {
                isSaved = false;
                //throw ex;
            }

            return(isSaved);
        }
예제 #7
0
        public int SaveRecieptVoucher(RecieptVoucherModel objReciept)
        {
            string Query = string.Empty;
            int    recid = 0;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Series", objReciept.Voucher_Series));
                paramCollection.Add(new DBParameter("@Date", objReciept.RV_Date));
                paramCollection.Add(new DBParameter("@Voucher_Number", objReciept.Voucher_Number));
                paramCollection.Add(new DBParameter("@Type", objReciept.Type));
                paramCollection.Add(new DBParameter("@PDDate", objReciept.PDCDate));
                //paramCollection.Add(new DBParameter("@Long", objReciept.LongNarration));

                paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now));

                Query = "INSERT INTO Reciept_Voucher([Series],[Reciept_Date],[VoucherNo],[Type],[PDC_Date]," +
                        "[CreatedBy],[CreatedDate]) VALUES " +
                        "(@Series,@Date,@Voucher_Number,@Type,@PDDate, " +
                        " @CreatedBy,@CreatedDate)";

                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    SaveRecieptAccounts(objReciept.RecieptAccountModel);
                    recid = GetRecieptId();
                }
            }
            catch (Exception ex)
            {
                recid = 0;
                throw ex;
            }

            return(recid);
        }
예제 #8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            RecieptVoucherModel objRecipt = new RecieptVoucherModel();

            if (tbxVchNumber.Text.Trim() == "")
            {
                MessageBox.Show("Voucher Number Can Not Be Blank!");
                return;
            }
            objRecipt.Voucher_Series = tbxVoucherSeries.Text.Trim();
            objRecipt.Voucher_Number = Convert.ToInt32(tbxVchNumber.Text.Trim());
            objRecipt.RV_Date        = Convert.ToDateTime(dtDate.Text);
            objRecipt.Type           = tbxType.Text.Trim();
            objRecipt.PDCDate        = Convert.ToDateTime(dtPDCDate.Text);
            objRecipt.LongNarration  = tbxLongNarration.Text.Trim() == null ? string.Empty : tbxLongNarration.Text.Trim();
            if (objRecipt.LedgerId == 0)
            {
                objRecipt.TotalDebitAmt  = Convert.ToDecimal(colDebit.SummaryItem.SummaryValue);
                objRecipt.TotalCreditAmt = Convert.ToDecimal(colCredit.SummaryItem.SummaryValue);
            }
            else
            {
                objRecipt.TotalDebitAmt = Convert.ToDecimal(colCredit.SummaryItem.SummaryValue);
            }

            //Receipt Account Details
            AccountModel        objacc;
            List <AccountModel> lstAccounts = new List <AccountModel>();

            for (int i = 0; i < gdvReceipt.DataRowCount; i++)
            {
                DataRow row = gdvReceipt.GetDataRow(i);

                objacc          = new AccountModel();
                objacc.ParentId = Convert.ToInt32(row["ParentId"].ToString() == string.Empty?"0": row["ParentId"]);
                objacc.AC_Id    = Convert.ToInt32(row["Ac_Id"].ToString() == string.Empty ? "0" : row["Ac_Id"]);
                objacc.DC       = row["DC"].ToString();
                objacc.Account  = row["Account"].ToString();
                objacc.LedgerId = objAccBL.GetLedgerIdByAccountName(row["Account"].ToString());
                if (objRecipt.LedgerId == 0)
                {
                    objacc.Debit  = Convert.ToDecimal(row["Debit"].ToString() == string.Empty ? "0.00" : row["Debit"]);
                    objacc.Credit = Convert.ToDecimal(row["Credit"].ToString() == string.Empty ? "0.00" : row["Credit"]);
                }
                else
                {
                    objacc.Credit = Convert.ToDecimal(row["Credit"].ToString() == string.Empty ? "0.00" : row["Credit"]);
                }
                objacc.Narration = row["Narration"].ToString() == string.Empty ?string.Empty : row["Narration"].ToString();

                lstAccounts.Add(objacc);
            }
            objRecipt.RecieptAccountModel = lstAccounts;
            objRecipt.RV_Id = Recpt_Id;
            bool isSuccess = objRecBL.UpdateRecieptVoucher(objRecipt);

            if (isSuccess)
            {
                MessageBox.Show("Update Successfully!");
                Recpt_Id = 0;
                ClearFormValues();
                Transaction.List.ReceiptVouchersList frmList = new Transaction.List.ReceiptVouchersList();
                frmList.StartPosition = FormStartPosition.CenterScreen;

                frmList.ShowDialog();
                FillRecieptVoucherInfo();
            }
        }
예제 #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            RecieptVoucherModel objRecipt = new RecieptVoucherModel();

            if (tbxVchNumber.Text.Trim() == "")
            {
                MessageBox.Show("Voucher Number Can Not Be Blank!");
                return;
            }
            objRecipt.Voucher_Series = tbxVoucherSeries.Text.Trim();
            objRecipt.Voucher_Number = Convert.ToInt32(tbxVchNumber.Text.Trim());
            objRecipt.RV_Date        = Convert.ToDateTime(dtDate.Text);
            objRecipt.Type           = tbxType.Text.Trim();
            objRecipt.PDCDate        = Convert.ToDateTime(dtPDCDate.Text);
            objRecipt.LongNarration  = tbxLongNarration.Text.Trim() == string.Empty?string.Empty:tbxLongNarration.Text.Trim();
            objRecipt.LedgerId       = objAccBL.GetLedgerIdByAccountName(cbxPayMode.Text.Trim() == null ? string.Empty : cbxPayMode.Text.Trim());
            if (objRecipt.LedgerId == 0)
            {
                if (Convert.ToDecimal(colCredit.SummaryItem.SummaryValue) != Convert.ToDecimal(colDebit.SummaryItem.SummaryValue))
                {
                    gdvReceipt.Focus();
                    return;
                }
                objRecipt.TotalDebitAmt  = Convert.ToDecimal(colDebit.SummaryItem.SummaryValue);
                objRecipt.TotalCreditAmt = Convert.ToDecimal(colCredit.SummaryItem.SummaryValue);
            }
            else
            {
                objRecipt.TotalDebitAmt = Convert.ToDecimal(colCredit.SummaryItem.SummaryValue);
            }

            //Receipt Account Details
            AccountModel        objacc;
            List <AccountModel> lstAccounts = new List <AccountModel>();

            for (int i = 0; i < gdvReceipt.DataRowCount; i++)
            {
                DataRow row = gdvReceipt.GetDataRow(i);

                objacc          = new AccountModel();
                objacc.DC       = row["DC"].ToString();
                objacc.Account  = row["Account"].ToString();
                objacc.LedgerId = objAccBL.GetLedgerIdByAccountName(row["Account"].ToString());
                if (objRecipt.LedgerId == 0)
                {
                    objacc.Debit  = Convert.ToDecimal(row["Debit"].ToString() == string.Empty ? "0.00" : row["Debit"]);
                    objacc.Credit = Convert.ToDecimal(row["Credit"].ToString() == string.Empty ? "0.00" : row["Credit"]);
                }
                else
                {
                    objacc.Credit = Convert.ToDecimal(row["Credit"].ToString() == string.Empty ? "0.00" : row["Credit"]);
                }
                objacc.Narration = row["Narration"].ToString() == string.Empty ? string.Empty : row["Narration"].ToString();
                lstAccounts.Add(objacc);
            }
            objRecipt.RecieptAccountModel = lstAccounts;

            bool isSuccess = objRecBL.SaveRecieptVoucher(objRecipt);

            if (isSuccess)
            {
                MessageBox.Show("Saved Successfully!");
                Recpt_Id = 0;
                //ClearFormValues();
            }
        }
예제 #10
0
        //Udate Reciept Voucher
        public bool UpdateRecieptVoucher(RecieptVoucherModel objRecipt)
        {
            string Query     = string.Empty;
            bool   isUpdated = true;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Series", objRecipt.Voucher_Series));
                paramCollection.Add(new DBParameter("@Date", objRecipt.RV_Date, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@Voucher_Number", objRecipt.Voucher_Number));
                paramCollection.Add(new DBParameter("@Type", objRecipt.Type));
                paramCollection.Add(new DBParameter("@LedgerId", objRecipt.LedgerId));
                paramCollection.Add(new DBParameter("@PDDate", objRecipt.PDCDate, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@LongNarration", objRecipt.LongNarration));
                paramCollection.Add(new DBParameter("@TotalCreditAmt", objRecipt.TotalCreditAmt, System.Data.DbType.Decimal));
                paramCollection.Add(new DBParameter("@TotalDebitAmt", objRecipt.TotalDebitAmt, System.Data.DbType.Decimal));

                paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@id", objRecipt.RV_Id));

                Query = "UPDATE Reciept_Voucher_Master SET `Series`=@Series,`LedgerId`=LedgerId,`Reciept_Date`=@Date,`VoucherNo`=@Voucher_Number," +
                        "`Type`=@Type,`PDC_Date`=@PDDate,`LongNarration`=@LongNarration,`TotalCreditAmt`=@TotalCreditAmt,`TotalDebitAmt`=@TotalDebitAmt,`CreatedBy`=CreatedBy,`CreatedDate`=CreatedDate,`ModifiedBy`=@ModifiedBy," +
                        "`ModifiedDate`=@ModifiedDate " +
                        "WHERE `Reciept_Id`=@id";

                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    List <AccountModel> lstAcct = new List <AccountModel>();

                    foreach (AccountModel act in objRecipt.RecieptAccountModel)
                    {
                        act.ParentId = Convert.ToInt32(objRecipt.RV_Id);
                        if (act.AC_Id > 0)
                        {
                            paramCollection = new DBParameterCollection();

                            paramCollection.Add(new DBParameter("@DC", (act.DC)));
                            paramCollection.Add(new DBParameter("@Account", act.Account));
                            paramCollection.Add(new DBParameter("@LegderId", act.LedgerId));
                            paramCollection.Add(new DBParameter("@Debit", act.Debit, System.Data.DbType.Decimal));
                            paramCollection.Add(new DBParameter("@Credit", act.Credit, System.Data.DbType.Decimal));
                            paramCollection.Add(new DBParameter("@Narration", act.Narration));

                            paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                            paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now, System.Data.DbType.DateTime));
                            paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                            paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now, System.Data.DbType.DateTime));
                            paramCollection.Add(new DBParameter("@ACT_ID", act.AC_Id));
                            paramCollection.Add(new DBParameter("@ParentId", act.ParentId));

                            Query = "UPDATE Reciept_Voucher_Details SET `DC`=@DC," +
                                    "`Account`=@Account,`Debit`=@Debit,`Credit`=@Credit,`Narration`=@Narration,`CreatedBy`=CreatedBy,`CreatedDate`=CreatedDate,`ModifiedBy`=@ModifiedBy,`ModifiedDate`=@ModifiedDate,`LegderId`=@LegderId " +
                                    "WHERE `AC_Id`=@ACT_ID AND `Reciept_Id`=@ParentId";

                            if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                            {
                                isUpdated = true;
                            }
                        }
                        else
                        {
                            paramCollection = new DBParameterCollection();

                            paramCollection.Add(new DBParameter("@RecieptId", (objRecipt.RV_Id)));
                            paramCollection.Add(new DBParameter("@DC", (act.DC)));
                            paramCollection.Add(new DBParameter("@Account", act.Account));
                            paramCollection.Add(new DBParameter("@LegderId", act.LedgerId));
                            paramCollection.Add(new DBParameter("@DebitAmount", act.Debit, System.Data.DbType.Decimal));
                            paramCollection.Add(new DBParameter("@CreditAmount", act.Credit, System.Data.DbType.Decimal));
                            paramCollection.Add(new DBParameter("@Narration", act.Narration));
                            paramCollection.Add(new DBParameter("@CreatedBy", ""));
                            paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now, System.Data.DbType.DateTime));
                            paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                            paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now, System.Data.DbType.DateTime));

                            System.Data.IDataReader dr =
                                _dbHelper.ExecuteDataReader("spInsertRecieptDetails", _dbHelper.GetConnObject(), paramCollection, System.Data.CommandType.StoredProcedure);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                isUpdated = false;
                //throw ex;
            }

            return(isUpdated);
        }
예제 #11
0
        //Udate Reciept Voucher
        public bool UpdateRecieptVoucher(RecieptVoucherModel objRecipt)
        {
            string Query     = string.Empty;
            bool   isUpdated = true;

            try
            {
                //UPDATE CREDIT NOTE TABLE - PARENT TABLE

                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Series", objRecipt.Voucher_Series));
                paramCollection.Add(new DBParameter("@Date", objRecipt.RV_Date));
                paramCollection.Add(new DBParameter("@Voucher_Number", objRecipt.Voucher_Number));
                paramCollection.Add(new DBParameter("@Type", objRecipt.Type));
                paramCollection.Add(new DBParameter("@PDDate", objRecipt.PDCDate));
                //paramCollection.Add(new DBParameter("@TotalCreditAmt", "0"));
                //paramCollection.Add(new DBParameter("@TotalDebitAmt", "0"));

                paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now));
                paramCollection.Add(new DBParameter("@id", objRecipt.RV_Id));

                Query = "UPDATE Reciept_Voucher SET [Series]=@Series,[Reciept_Date]=@Date,[VoucherNo]=@Voucher_Number," +
                        "[Type]=@Type,[PDC_Date]=@PDDate,[ModifiedBy]=@ModifiedBy," +
                        "[ModifiedDate]=@ModifiedDate " +
                        "WHERE Reciept_Id=@id";

                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    List <AccountModel> lstAcct = new List <AccountModel>();

                    //UPDATE CREDIT NOTE ACCOUNT -CHILD TABLE UPDATES
                    foreach (AccountModel act in objRecipt.RecieptAccountModel)
                    {
                        if (act.AC_Id > 0)
                        {
                            paramCollection = new DBParameterCollection();

                            paramCollection.Add(new DBParameter("@DC", (act.DC)));
                            paramCollection.Add(new DBParameter("@Account", act.Account));
                            paramCollection.Add(new DBParameter("@Debit", act.Debit));
                            paramCollection.Add(new DBParameter("@Credit", act.Credit));
                            paramCollection.Add(new DBParameter("@Narration", act.Narration));

                            paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                            paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now));
                            paramCollection.Add(new DBParameter("@ACT_ID", act.AC_Id));

                            Query = "UPDATE Reciept_Voucher_Accounts SET [DC]=@DC," +
                                    "[Account]=@Account,[Debit]=@Debit,[Credit]=@Credit,[Narration]=@Narration,[ModifiedBy]=@ModifiedBy,[ModifiedDate]=@ModifiedDate " +
                                    "WHERE [AC_Id]=@ACT_ID";

                            if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                            {
                                isUpdated = true;
                            }
                        }
                        else
                        {
                            paramCollection = new DBParameterCollection();

                            paramCollection.Add(new DBParameter("@DN_ID", (act.ParentId)));
                            paramCollection.Add(new DBParameter("@DC", (act.DC)));
                            paramCollection.Add(new DBParameter("@Account", act.Account));
                            paramCollection.Add(new DBParameter("@Debit", act.Debit));
                            paramCollection.Add(new DBParameter("@Credit", act.Credit));
                            paramCollection.Add(new DBParameter("@Narration", act.Narration));

                            paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                            paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now));

                            Query = "INSERT INTO Reciept_Voucher_Accounts([Reciept_Id],[DC],[Account],[Debit]," +
                                    "[Credit],[Narration],[CreatedBy],[CreatedDate]) VALUES " +
                                    "(@RV_ID,@DC,@Account,@Debit,@Credit,@Narration,@CreatedBy,@CreatedDate)";

                            if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                            {
                                isUpdated = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                isUpdated = false;
                throw ex;
            }

            return(isUpdated);
        }