public bool UpdatePurchaseVoucher(eSunSpeedDomain.PurchaseVoucherModel objpv)
        {
            string Query     = string.Empty;
            bool   isUpdated = false;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Series", objpv.Series));
                paramCollection.Add(new DBParameter("@PurchaseType", objpv.PurchaseType));
                paramCollection.Add(new DBParameter("@PurchaseDate", objpv.PV_Date));
                paramCollection.Add(new DBParameter("@VoucherNumber", objpv.Voucher_Number));
                paramCollection.Add(new DBParameter("@BillNumber", objpv.BillNo));

                paramCollection.Add(new DBParameter("@Party", objpv.Party));
                paramCollection.Add(new DBParameter("@MatCentre", objpv.MatCenter));

                paramCollection.Add(new DBParameter("@Narration", objpv.Narration));
                paramCollection.Add(new DBParameter("@TotalQty", objpv.TotalQty, System.Data.DbType.Decimal));
                paramCollection.Add(new DBParameter("@TotalAmount", objpv.TotalAmount, System.Data.DbType.Decimal));
                paramCollection.Add(new DBParameter("@BSTotalAmount", objpv.BSTotalAmount, System.Data.DbType.Decimal));

                paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                //paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now));
                paramCollection.Add(new DBParameter("@PurchaseVoucher_ID", objpv.PV_Id));

                Query = "UPDATE Trans_Purchase_Voucher SET [Series]=@Series,[PV_Type]=@PurchaseType,[PV_Date]=@PurchaseDate," +
                        "[VoucherNo]=@VoucherNumber,[BillNo]=@BillNumber," +
                        "[Party]=@Party,[MatCenter]=@MatCentre," +
                        "[Narration]=@Narration,[TotalQty]=@TotalQty," +
                        "[TotalAmount]=@TotalAmount,[BSTotalAmount]=@BSTotalAmount," +
                        "[ModifiedBy]=@ModifiedBy " +
                        "WHERE TransPVId=@PurchaseVoucher_ID;";

                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    UpdatePurchaseItemandBS(objpv);
                    isUpdated = true;
                }
            }

            catch (Exception ex)
            {
                isUpdated = false;
                throw ex;
            }

            return(isUpdated);
        }
Exemple #2
0
        //Update Purchase Voucher
        public bool UpdatePurchaseVoucher(eSunSpeedDomain.PurchaseVoucherModel objPurc)
        {
            string Query    = string.Empty;
            bool   isUpdate = true;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Trans_Purc_Id", objPurc.Trans_Purc_Id));
                paramCollection.Add(new DBParameter("@VoucherType", objPurc.VoucherType));
                paramCollection.Add(new DBParameter("@PurcDate", objPurc.PurcDate, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@Terms", objPurc.Terms));
                paramCollection.Add(new DBParameter("@VoucherNumber", objPurc.VoucherNumber));
                paramCollection.Add(new DBParameter("@BillNumber", objPurc.BillNo));
                paramCollection.Add(new DBParameter("@LedgerId", objPurc.LedgerId));
                paramCollection.Add(new DBParameter("@PurcType", objPurc.PurcType));
                paramCollection.Add(new DBParameter("@MatCentre", objPurc.MatCentre));
                paramCollection.Add(new DBParameter("@Narration", objPurc.Narration));
                paramCollection.Add(new DBParameter("@TotalAmount", objPurc.TotalAmount, DbType.Decimal));
                paramCollection.Add(new DBParameter("@TotalQty", objPurc.TotalQty, DbType.Decimal));
                paramCollection.Add(new DBParameter("@TotalFree", objPurc.TotalFree, DbType.Decimal));
                paramCollection.Add(new DBParameter("@TotalBasicAmount", objPurc.TotalBasicAmount, DbType.Decimal));
                paramCollection.Add(new DBParameter("@TotalDisAmount", objPurc.TotalDisAmount, DbType.Decimal));
                paramCollection.Add(new DBParameter("@TotalTaxAmount", objPurc.TotalTaxAmount, DbType.Decimal));
                paramCollection.Add(new DBParameter("@BSTotalAmount", objPurc.BSTotalAmount, DbType.Decimal));
                paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now, DbType.DateTime));
                paramCollection.Add(new DBParameter("@ModifiedBy", ""));
                paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now, DbType.DateTime));

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

                foreach (Item_VoucherModel item in objPurc.Item_Voucher)
                {
                    item.ParentId = objPurc.Trans_Purc_Id;
                    if (item.Item_ID > 0)
                    {
                        paramCollection = new DBParameterCollection();

                        paramCollection.Add(new DBParameter("@ParentId", item.ParentId));
                        paramCollection.Add(new DBParameter("@IId", item.Item_ID));
                        paramCollection.Add(new DBParameter("@ITM_Id", item.ITM_Id));
                        paramCollection.Add(new DBParameter("@LedgerId", item.LedgerId));
                        paramCollection.Add(new DBParameter("@Qty", item.Qty, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@Unit", item.Unit));
                        paramCollection.Add(new DBParameter("@Per", item.Per));
                        paramCollection.Add(new DBParameter("@Price", item.Price, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@Batch", item.Batch));
                        paramCollection.Add(new DBParameter("@Free", item.Free, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@BasicAmt", item.BasicAmt, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@DiscountPercentage", item.DiscountPercentage, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@DiscountAmount", item.DiscountAmount, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@TaxAmount", item.TaxAmount, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@Amount", item.Amount, 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 drpv =
                            _dbHelper.ExecuteDataReader("spUpdatePurchaseVoucherItemDetails", _dbHelper.GetConnObject(), paramCollection, System.Data.CommandType.StoredProcedure);
                    }
                    else
                    {
                        paramCollection = new DBParameterCollection();

                        paramCollection.Add(new DBParameter("@ParentId", item.ParentId));
                        paramCollection.Add(new DBParameter("@ITM_Id", item.ITM_Id));
                        paramCollection.Add(new DBParameter("@LedgerId", item.LedgerId));
                        paramCollection.Add(new DBParameter("@Qty", item.Qty, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@Unit", item.Unit));
                        paramCollection.Add(new DBParameter("@Per", item.Per));
                        paramCollection.Add(new DBParameter("@Price", item.Price, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@Batch", item.Batch));
                        paramCollection.Add(new DBParameter("@Free", item.Free, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@BasicAmt", item.BasicAmt, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@DiscountPercentage", item.DiscountPercentage, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@DiscountAmount", item.DiscountAmount, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@TaxAmount", item.TaxAmount, DbType.Decimal));
                        paramCollection.Add(new DBParameter("@Amount", item.Amount, 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 drpv =
                            _dbHelper.ExecuteDataReader("spInsertPurchaseVoucherItemDetails", _dbHelper.GetConnObject(), paramCollection, System.Data.CommandType.StoredProcedure);
                    }
                }
                foreach (BillSundry_VoucherModel bs in objPurc.BillSundry_Voucher)
                {
                    bs.ParentId = objPurc.Trans_Purc_Id;
                    if (bs.BSId > 0)
                    {
                        paramCollection = new DBParameterCollection();

                        paramCollection.Add(new DBParameter("@ParentId", bs.ParentId));
                        paramCollection.Add(new DBParameter("@BSId", bs.BSId));
                        paramCollection.Add(new DBParameter("@BS_Id", bs.BS_Id));
                        paramCollection.Add(new DBParameter("@Percentage", bs.Percentage));
                        paramCollection.Add(new DBParameter("@Extra", bs.Extra));
                        paramCollection.Add(new DBParameter("@Amount", bs.Amount));
                        paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                        paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now, DbType.DateTime));
                        paramCollection.Add(new DBParameter("@ModifiedBy", ""));
                        paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now, DbType.DateTime));

                        System.Data.IDataReader drbs =
                            _dbHelper.ExecuteDataReader("spUpdatePurchaseVoucherBS", _dbHelper.GetConnObject(), paramCollection, System.Data.CommandType.StoredProcedure);
                    }
                    else
                    {
                        paramCollection = new DBParameterCollection();

                        paramCollection.Add(new DBParameter("@ParentId", bs.ParentId));
                        paramCollection.Add(new DBParameter("@BS_Id", bs.BS_Id));
                        paramCollection.Add(new DBParameter("@Percentage", bs.Percentage));
                        paramCollection.Add(new DBParameter("@Extra", bs.Extra));
                        paramCollection.Add(new DBParameter("@Amount", bs.Amount));
                        paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                        paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now, DbType.DateTime));
                        paramCollection.Add(new DBParameter("@ModifiedBy", ""));
                        paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now, DbType.DateTime));

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

            return(isUpdate);
        }