示例#1
0
        public prj0010(int itemDemandMasterId)
        {
            InitializeComponent();
            _itemDemandMasterId = itemDemandMasterId;
            var demandMaster     = dbContext.ItemDemandMaster.Find(_itemDemandMasterId);
            var existStockMaster = dbContext.StockMaster.FirstOrDefault(x => x.STOCKMASTER_REF_ID == _itemDemandMasterId && x.STOCKMASTER_REF_LINK == "ItemDemandMaster");

            if (existStockMaster == null)
            {
                var stockMaster = new StockMaster
                {
                    STOCKMASTER_COMPANY_ID     = demandMaster.Project.PROJECT_COMPANY_ID,
                    STOCKMASTER_SOURCESTORE_ID = demandMaster.Project.Company.COMPANY_STORE_ID.Value,
                    STOCKMASTER_TARGETSTORE_ID = demandMaster.Project.Company.COMPANY_STORE_ID.Value,
                    STOCKMASTER_TYPE_ID        = StaticTypes.DemandTransfer,
                    STOCKMASTER_REF_ID         = _itemDemandMasterId,
                    STOCKMASTER_REF_LINK       = "ItemDemandMaster"
                };
                dbContext.StockMaster.Add(stockMaster);
                dbContext.SaveChanges();
                _stockMasterId = stockMaster.ID;
            }
            else
            {
                _stockMasterId = existStockMaster.ID;
            }
            storeBindingSource.DataSource = dbContext.ParameterDetail.Where(x => x.PARAMETERDETAIL_MASTER_ID == StaticTypes.Store).ToList();
            LoadData();
        }
        public ActionResult Edit([Bind(Include = "CustomerId,RecordId,StoreId, ClassId, ItemId,BatchNo,Quantity,UomId,VendorId,PInvoiceNo,ReciveDate,TotalPrice")] StockMaster item)
        {
            StockMaster i = (from c in db.StockMasters
                             where c.RecordId == item.RecordId
                             select c).FirstOrDefault();

            ModelState.Remove("EmployeeID");
            if (ModelState.IsValid)
            {
                i.EmployeeID  = Convert.ToInt32(@Session["employeecode"]);
                i.StoreId     = item.StoreId;
                i.ClassId     = item.ClassId;
                i.ItemId      = item.ItemId;
                i.BatchNo     = item.BatchNo;
                i.UomId       = item.UomId;
                i.VendorId    = item.VendorId;
                i.BatchNo     = item.BatchNo;
                i.Quantity    = item.Quantity;
                i.UomId       = item.UomId;
                i.PInvoiceNo  = item.PInvoiceNo;
                i.TotalPrice  = item.TotalPrice;
                i.ReciveDate  = item.ReciveDate;
                i.CreatedDate = DateTime.Now;
                db.SaveChanges();
            }
            return(RedirectToAction("ViewAll"));
        }
示例#3
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            int targetStore = (int)lueTargetStore.EditValue;
            int sourceStore = (int)lueSourceStore.EditValue;

            stockDetailDropdown.DataSource = StockHelper.GetStoreStocks(targetStore).Where(x => x.STOCKDETAIL_QUANTITY > 0);
            StockMaster stockMaster2 = new StockMaster()
            {
                STOCKMASTER_TARGETSTORE_ID = targetStore,
                STOCKMASTER_SOURCESTORE_ID = sourceStore,
                STOCKMASTER_TYPE_ID        = StaticTypes.Entry,
            };

            dbContext.StockMaster.Add(stockMaster2);
            dbContext.SaveChanges();
            StockMaster stockMaster = new StockMaster()
            {
                STOCKMASTER_TARGETSTORE_ID = targetStore,
                STOCKMASTER_SOURCESTORE_ID = sourceStore,
                STOCKMASTER_TYPE_ID        = StaticTypes.Output,
                STOCKMASTER_REF_ID         = stockMaster2.ID,
                STOCKMASTER_REF_LINK       = "StockMaster"
            };

            dbContext.StockMaster.Add(stockMaster);
            dbContext.SaveChanges();
            _stockMasterId         = stockMaster.ID;
            _stockMasterIdEntry    = stockMaster2.ID;
            lueTargetStore.Enabled = false;
            lueSourceStore.Enabled = false;
            gControlDetail.Enabled = true;
        }
        public ActionResult Create([Bind(Include = "CustomerId,StoreId, ClassId, ItemId,BatchNo,Quantity,UomId,VendorId,PInvoiceNo,ReciveDate,TotalPrice")] StockMaster item)
        {
            StockMaster i = new StockMaster();

            ModelState.Remove("EmployeeID");
            if (ModelState.IsValid)
            {
                i.EmployeeID  = Convert.ToInt32(@Session["employeecode"]);
                i.StoreId     = item.StoreId;
                i.ClassId     = item.ClassId;
                i.ItemId      = item.ItemId;
                i.BatchNo     = item.BatchNo;
                i.UomId       = item.UomId;
                i.VendorId    = item.VendorId;
                i.BatchNo     = item.BatchNo;
                i.Quantity    = item.Quantity;
                i.UomId       = item.UomId;
                i.PInvoiceNo  = item.PInvoiceNo;
                i.TotalPrice  = item.TotalPrice;
                i.ReciveDate  = item.ReciveDate;
                i.CreatedDate = DateTime.Now;
                db.StockMasters.Add(i);
                db.SaveChanges();
            }
            return(RedirectToAction("Create"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            StockMaster ven = db.StockMasters.Find(id);

            db.StockMasters.Remove(ven);
            db.SaveChanges();
            return(RedirectToAction("ViewAll"));
        }
示例#6
0
        public ActionResult DeleteConfirmed(int id)
        {
            StockMaster stockMaster = db.StockMasters.Find(id);

            db.StockMasters.Remove(stockMaster);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#7
0
        public int InsertRecord(ref StockMaster Entity_StockMaster, Int32 LOCID, out string strError)
        {
            int iInsert = 0;

            strError = string.Empty;
            try
            {
                SqlParameter pAction          = new SqlParameter(StockMaster._Action, SqlDbType.BigInt);
                SqlParameter pStockNo         = new SqlParameter(StockMaster._StockNo, SqlDbType.NVarChar);
                SqlParameter pStockDate       = new SqlParameter(StockMaster._StockAsOn, SqlDbType.DateTime);
                SqlParameter pConsumptionDate = new SqlParameter(StockMaster._ConsumptionDate, SqlDbType.DateTime);
                SqlParameter pType            = new SqlParameter(StockMaster._Type, SqlDbType.Char);

                SqlParameter pCreatedBy   = new SqlParameter(PurchaseOrder._UserId, SqlDbType.BigInt);
                SqlParameter pCreatedDate = new SqlParameter(PurchaseOrder._LoginDate, SqlDbType.DateTime);
                SqlParameter pIsDeleted   = new SqlParameter(PurchaseOrder._IsDeleted, SqlDbType.Bit);
                SqlParameter pLOCID       = new SqlParameter("@LOCID", SqlDbType.BigInt);
                SqlParameter pRemark      = new SqlParameter("@Remark", SqlDbType.NVarChar);

                pAction.Value          = 1;
                pStockNo.Value         = Entity_StockMaster.StockNo;
                pStockDate.Value       = Entity_StockMaster.StockAsOn;
                pConsumptionDate.Value = Entity_StockMaster.ConsumptionDate;
                pType.Value            = Entity_StockMaster.Type;
                pCreatedBy.Value       = Entity_StockMaster.UserId;
                pCreatedDate.Value     = Entity_StockMaster.LoginDate;
                pIsDeleted.Value       = Entity_StockMaster.IsDeleted;
                pLOCID.Value           = LOCID;
                pRemark.Value          = Entity_StockMaster.Remark;
                SqlParameter[] Param = new SqlParameter[] { pAction, pStockNo, pConsumptionDate, pStockDate, pType, pCreatedBy, pCreatedDate, pIsDeleted, pLOCID, pRemark };

                Open(CONNECTION_STRING);
                BeginTransaction();

                iInsert = SQLHelper.ExecuteScalar(_Connection, _Transaction, CommandType.StoredProcedure, StockMaster.SP_StockMaster, Param);

                if (iInsert > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                strError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(iInsert);
        }
示例#8
0
 public ActionResult Edit([Bind(Include = "StockId,StockCode,StockDescription,Cost,SellingPrice,QtyPurchased,QtySold,StockOnHand,TotalPurchasesExclVat,TotalSalesexclvat")] StockMaster stockMaster)
 {
     if (ModelState.IsValid)
     {
         stockMaster.StockOnHand     = stockMaster.calcSold();
         db.Entry(stockMaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(stockMaster));
 }
示例#9
0
        public static long Add(string catalog, int officeId, int userId, long loginId, string book, DateTime valueDate, string partyCode, int priceTypeId, Collection <StockDetail> details, string referenceNumber, string statementReference, Collection <long> transactionIdCollection, Collection <Attachment> attachments)
        {
            StockMaster stockMaster = new StockMaster();

            stockMaster.PartyCode   = partyCode;
            stockMaster.PriceTypeId = priceTypeId;

            long nonGlStockMasterId = NonGlStockTransaction.Add(catalog, book, valueDate, officeId, userId, loginId, referenceNumber, statementReference, stockMaster, details, transactionIdCollection, attachments);

            return(nonGlStockMasterId);
        }
示例#10
0
        public static long Add(string book, DateTime valueDate, string partyCode, int priceTypeId, Collection <StockDetail> details, string referenceNumber, string statementReference, Collection <long> transactionIdCollection, Collection <Attachment> attachments)
        {
            StockMaster stockMaster = new StockMaster();

            stockMaster.PartyCode   = partyCode;
            stockMaster.PriceTypeId = priceTypeId;

            long nonGlStockMasterId = NonGlStockTransaction.Add(book, valueDate, CurrentSession.GetOfficeId(), CurrentSession.GetUserId(), CurrentSession.GetLogOnId(), referenceNumber, statementReference, stockMaster, details, transactionIdCollection, attachments);

            return(nonGlStockMasterId);
        }
示例#11
0
        public int UpdateRecord(ref StockMaster Entity_StockMaster, out string strError)
        {
            int iInsert = 0;

            strError = string.Empty;
            try
            {
                SqlParameter pAction          = new SqlParameter(StockMaster._Action, SqlDbType.BigInt);
                SqlParameter pStockNo         = new SqlParameter(StockMaster._StockNo, SqlDbType.NVarChar);
                SqlParameter pStockDate       = new SqlParameter(StockMaster._StockAsOn, SqlDbType.DateTime);
                SqlParameter pConsumptionDate = new SqlParameter(StockMaster._ConsumptionDate, SqlDbType.DateTime);
                SqlParameter pOutwardId       = new SqlParameter(StockMaster._OutwardId, SqlDbType.BigInt);
                SqlParameter pUpdatedBy       = new SqlParameter(StockMaster._UserId, SqlDbType.BigInt);
                SqlParameter pUpdatedDate     = new SqlParameter(StockMaster._LoginDate, SqlDbType.DateTime);
                SqlParameter pRemark          = new SqlParameter("@Remark", SqlDbType.NVarChar);


                pAction.Value          = 2;
                pStockNo.Value         = Entity_StockMaster.StockNo;
                pStockDate.Value       = Entity_StockMaster.StockAsOn;
                pConsumptionDate.Value = Entity_StockMaster.ConsumptionDate;
                pOutwardId.Value       = Entity_StockMaster.OutwardId;
                pUpdatedBy.Value       = Entity_StockMaster.UserId;
                pUpdatedDate.Value     = Entity_StockMaster.LoginDate;
                pRemark.Value          = Entity_StockMaster.Remark;

                SqlParameter[] Param = new SqlParameter[] { pAction, pStockNo, pStockDate, pConsumptionDate, pOutwardId, pUpdatedBy, pUpdatedDate, pRemark };

                Open(CONNECTION_STRING);
                BeginTransaction();

                iInsert = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, StockMaster.SP_StockMaster, Param);

                if (iInsert > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                strError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(iInsert);
        }
示例#12
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            var stockMaster = new StockMaster();

            stockMaster.STOCKMASTER_TARGETSTORE_ID = (int)lueTargetStore.EditValue;
            stockMaster.STOCKMASTER_SOURCESTORE_ID = (int)lueStore.EditValue;
            stockMaster.STOCKMASTER_TYPE_ID        = StaticTypes.ReturnShipping;
            dbContext.StockMaster.Add(stockMaster);
            dbContext.SaveChanges();
            _stockMasterId         = stockMaster.ID;
            gControlMaster.Enabled = false;
            gControlDetail.Enabled = true;
        }
示例#13
0
        // GET: StockMasters/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StockMaster stockMaster = db.StockMasters.Find(id);

            if (stockMaster == null)
            {
                return(HttpNotFound());
            }
            return(View(stockMaster));
        }
示例#14
0
        public StockMaster GetStockMasterByID(long id)
        {
            StockMaster stockMaster = new StockMaster();

            stockMaster = Database.StockMasters.Single(s => s.IID == id && s.IsRemoved == 0);
            if (stockMaster.ReferenceTypeID == Convert.ToInt32(EnumCollection.ReferenceType.Supplier))
            {
                using (TheFacade _facade = new TheFacade())
                {
                    Supplier supplier = _facade.SupplierFacade.GetSupplierByID(stockMaster.ReferenceID);
                    stockMaster.Supplier = supplier;
                }
            }
            return(stockMaster);
        }
示例#15
0
文件: Order.cs 项目: ududsha/mixerp
        public static long Add(int officeId, int userId, long loginId, DateTime valueDate, string partyCode, int priceTypeId, Collection <StockDetail> details, string referenceNumber, string statementReference, Collection <long> transactionIdCollection, Collection <Attachment> attachments, bool nonTaxable, int salesPersonId, int shipperId, string shippingAddressCode, int storeId)
        {
            StockMaster stockMaster = new StockMaster();

            stockMaster.PartyCode           = partyCode;
            stockMaster.PriceTypeId         = priceTypeId;
            stockMaster.SalespersonId       = salesPersonId;
            stockMaster.ShipperId           = shipperId;
            stockMaster.ShippingAddressCode = shippingAddressCode;
            stockMaster.StoreId             = storeId;

            long nonGlStockMasterId = NonGlStockTransaction.Add("Sales.Order", valueDate, officeId, userId, loginId, referenceNumber, statementReference, stockMaster, details, transactionIdCollection, attachments, nonTaxable);

            return(nonGlStockMasterId);
        }
示例#16
0
        public int DeleteRecord(ref StockMaster Entity_StockMaster, out string strError)
        {
            int iDelete = 0;

            strError = string.Empty;
            try
            {
                SqlParameter pAction    = new SqlParameter(StockMaster._Action, SqlDbType.BigInt);
                SqlParameter pOutwardId = new SqlParameter(StockMaster._OutwardId, SqlDbType.BigInt);

                SqlParameter pDeletedBy   = new SqlParameter(StockMaster._UserId, SqlDbType.BigInt);
                SqlParameter pDeletedDate = new SqlParameter(StockMaster._LoginDate, SqlDbType.DateTime);

                pAction.Value    = 3;
                pOutwardId.Value = Entity_StockMaster.OutwardId;

                pDeletedBy.Value   = Entity_StockMaster.UserId;
                pDeletedDate.Value = Entity_StockMaster.LoginDate;


                SqlParameter[] Param = new SqlParameter[] { pAction, pOutwardId, pDeletedBy, pDeletedDate };

                Open(CONNECTION_STRING);
                BeginTransaction();

                iDelete = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, StockMaster.SP_StockMaster, Param);

                if (iDelete > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                strError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(iDelete);
        }
示例#17
0
        public static long Add(DateTime valueDate, int storeId, string partyCode, Collection <StockDetail> details, int costCenterId, string referenceNumber, string statementReference, Collection <long> transactionIdCollection, Collection <Attachment> attachments)
        {
            StockMaster stockMaster = new StockMaster();

            stockMaster.PartyCode = partyCode;
            stockMaster.StoreId   = storeId;
            stockMaster.IsCredit  = true;

            if (!string.IsNullOrWhiteSpace(statementReference))
            {
                statementReference = statementReference.Replace("&nbsp;", " ").Trim();
            }

            long transactionMasterId = GlTransaction.Add(valueDate, "Purchase.Receipt", CurrentSession.GetOfficeId(), CurrentSession.GetUserId(), CurrentSession.GetLogOnId(), costCenterId, referenceNumber, statementReference, stockMaster, details, transactionIdCollection, attachments);

            return(transactionMasterId);
        }
示例#18
0
        public static long Add(string catalog, int officeId, int userId, long loginId, DateTime valueDate, int storeId, bool isCredit, string partyCode, Collection <StockDetail> details, int costCenterId, string referenceNumber, string statementReference, Collection <Attachment> attachments)
        {
            StockMaster stockMaster = new StockMaster();

            stockMaster.PartyCode = partyCode;
            stockMaster.StoreId   = storeId;
            stockMaster.IsCredit  = isCredit;

            if (!string.IsNullOrWhiteSpace(statementReference))
            {
                statementReference = statementReference.Replace("&nbsp;", " ").Trim();
            }

            long transactionMasterId = GlTransaction.Add(catalog, valueDate, "Purchase.Direct", officeId, userId, loginId, costCenterId, referenceNumber, statementReference, stockMaster, details, new Collection <long>(), attachments);

            return(transactionMasterId);
        }
示例#19
0
        public static long Add(string catalog, int officeId, int userId, long loginId, DateTime valueDate, int storeId, bool isCredit, int paymentTermId, string partyCode, int agentId, int priceTypeId, Collection <StockDetail> details, int shipperId, string shippingAddressCode, decimal shippingCharge, int costCenterId, string referenceNumber, string statementReference, Collection <Attachment> attachments, bool nonTaxable)
        {
            StockMaster stockMaster = new StockMaster();

            stockMaster.PartyCode           = partyCode;
            stockMaster.IsCredit            = isCredit;
            stockMaster.PaymentTermId       = paymentTermId;
            stockMaster.PriceTypeId         = priceTypeId;
            stockMaster.ShipperId           = shipperId;
            stockMaster.ShippingAddressCode = shippingAddressCode;
            stockMaster.ShippingCharge      = shippingCharge;
            stockMaster.SalespersonId       = agentId;
            stockMaster.StoreId             = storeId;

            long transactionMasterId = GlTransaction.Add(catalog, "Sales.Direct", valueDate, officeId, userId, loginId, costCenterId, referenceNumber, statementReference, stockMaster, details, attachments, nonTaxable, null);

            return(transactionMasterId);
        }
示例#20
0
        public int UpdateStatusFlag(string Status, ref StockMaster Entity_StockMaster, out string strError)
        {
            int iInsert = 0;

            strError = string.Empty;
            try
            {
                SqlParameter pAction    = new SqlParameter(StockMaster._Action, SqlDbType.BigInt);
                SqlParameter pOutwardId = new SqlParameter(StockMaster._OutwardId, SqlDbType.BigInt);
                SqlParameter pStatus    = new SqlParameter(StockMaster._Status, SqlDbType.NVarChar);
                SqlParameter pInwardId  = new SqlParameter(StockMaster._InwardId, SqlDbType.BigInt);
                pAction.Value    = 19;
                pOutwardId.Value = Entity_StockMaster.OutwardId;
                pStatus.Value    = Status;
                pInwardId.Value  = Entity_StockMaster.InwardId;
                SqlParameter[] Param = new SqlParameter[] { pAction, pOutwardId, pStatus, pInwardId };

                Open(CONNECTION_STRING);
                BeginTransaction();

                iInsert = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, StockMaster.SP_StockMaster1, Param);

                if (iInsert > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                strError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(iInsert);
        }
 public bool AddStock(StockModel stockModel)
 {
     try
     {
         _StockDbEntities = new StockDbEntities();
         StockMaster stockMaster = new StockMaster();
         stockMaster.StockId   = stockModel.StockId;
         stockMaster.StockName = stockModel.StockName;
         stockMaster.BuyPrice  = stockModel.BuyPrice;
         stockMaster.Qty       = stockModel.Qty;
         stockMaster.IsActive  = stockModel.IsActive;
         _StockDbEntities.StockMasters.Add(stockMaster);
         _StockDbEntities.SaveChanges();
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
示例#22
0
        public static long Add(DateTime valueDate, int storeId, string partyCode, int priceTypeId, int paymentTermId, Collection <StockDetail> details, int shipperId, string shippingAddressCode, decimal shippingCharge, int costCenterId, string referenceNumber, int agentId, string statementReference, Collection <int> transactionIdCollection, Collection <Attachment> attachments, bool nonTaxable)
        {
            StockMaster stockMaster = new StockMaster();

            stockMaster.PartyCode     = partyCode;
            stockMaster.IsCredit      = true; //Credit
            stockMaster.PaymentTermId = paymentTermId;

            stockMaster.PriceTypeId         = priceTypeId;
            stockMaster.ShipperId           = shipperId;
            stockMaster.ShippingAddressCode = shippingAddressCode;
            stockMaster.ShippingCharge      = shippingCharge;
            stockMaster.SalespersonId       = agentId;
            stockMaster.StoreId             = storeId;

            long transactionMasterId = GlTransaction.Add("Sales.Delivery", valueDate, CurrentSession.GetOfficeId(), CurrentSession.GetUserId(), CurrentSession.GetLogOnId(), costCenterId, referenceNumber, statementReference, stockMaster, details, attachments, nonTaxable);


            return(transactionMasterId);
        }
        public ActionResult Edit(int?id)
        {
            ViewBag.Store   = new SelectList(GetStore(), "Value", "Text");
            ViewBag.Class   = new SelectList(GetClass(), "Value", "Text");
            ViewBag.Item    = new SelectList(GetItem(), "Value", "Text");
            ViewBag.Uom     = new SelectList(GetUom(), "Value", "Text");
            ViewBag.Vendor  = new SelectList(GetVendor(), "Value", "Text");
            ViewBag.Invoice = new SelectList(GetInvoice(), "Value", "Text");
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StockMaster ven = db.StockMasters.Find(id);

            if (ven == null)
            {
                return(HttpNotFound());
            }
            return(View(ven));
        }
示例#24
0
        public int UpdateAssignFlag(ref StockMaster Entity_StockMaster, out string strError)
        {
            int iInsert = 0;

            strError = string.Empty;
            try
            {
                SqlParameter pAction   = new SqlParameter(StockMaster._Action, SqlDbType.BigInt);
                SqlParameter pInwardId = new SqlParameter(StockMaster._InwardId, SqlDbType.BigInt);


                pAction.Value   = 16;
                pInwardId.Value = Entity_StockMaster.InwardId;


                Open(CONNECTION_STRING);
                BeginTransaction();

                iInsert = SQLHelper.ExecuteNonQueryDoubleParm(_Connection, _Transaction, CommandType.StoredProcedure, StockMaster.SP_StockMaster1, pAction, pInwardId);

                if (iInsert > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                strError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(iInsert);
        }
示例#25
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            //if (validationResult() == true)
            //{
            var stockMaster = new StockMaster();

            stockMaster.STOCKMASTER_COMPANY_ID     = (int)lueCompany.EditValue;
            stockMaster.STOCKMASTER_SOURCESTORE_ID = (int)lueStore.EditValue;
            stockMaster.STOCKMASTER_TARGETSTORE_ID = (int)lueStore.EditValue;
            stockMaster.STOCKMASTER_TYPE_ID        = StaticTypes.Purchase;
            stockMaster.STOCKMASTER_WAYBILL_DATE   = dtpWayBillDate.EditValue.ToString();
            stockMaster.STOCKMASTER_WAYBILL_NO     = txtWayBillNo.EditValue.ToString();
            if (lueSubCompany.EditValue != string.Empty)
            {
                stockMaster.COMPANY_SUB_COMPANY_ID = (int)lueSubCompany.EditValue;
            }
            dbContext.StockMaster.Add(stockMaster);
            dbContext.SaveChanges();
            _stockMasterId         = stockMaster.ID;
            gControlMaster.Enabled = false;
            gControlDetail.Enabled = true;
            //}
        }
示例#26
0
        public static long Add(string bookName, DateTime valueDate, int officeId, int userId, long loginId, int costCenterId, string referenceNumber, string statementReference, StockMaster stockMaster, Collection <StockDetail> details, Collection <Attachment> attachments, bool nonTaxable, Collection <long> tranIds)
        {
            if (stockMaster == null)
            {
                return(0);
            }

            if (details == null)
            {
                return(0);
            }

            if (details.Count.Equals(0))
            {
                return(0);
            }

            string detail     = StockMasterDetailHelper.CreateStockMasterDetailParameter(details);
            string attachment = AttachmentHelper.CreateAttachmentModelParameter(attachments);
            string ids        = "NULL::bigint";

            if (tranIds != null && tranIds.Count > 0)
            {
                ids = string.Join(",", tranIds);
            }

            string sql = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM transactions.post_sales(@BookName, @OfficeId, @UserId, @LoginId, @ValueDate, @CostCenterId, @ReferenceNumber, @StatementReference, @IsCredit, @PaymentTermId, @PartyCode, @PriceTypeId, @SalespersonId, @ShipperId, @ShippingAddressCode, @StoreId, @NonTaxable, ARRAY[{0}], ARRAY[{1}], ARRAY[{2}])", detail, attachment, ids);

            using (NpgsqlCommand command = new NpgsqlCommand(sql))
            {
                command.Parameters.AddWithValue("@BookName", bookName);
                command.Parameters.AddWithValue("@OfficeId", officeId);
                command.Parameters.AddWithValue("@UserId", userId);
                command.Parameters.AddWithValue("@LoginId", loginId);
                command.Parameters.AddWithValue("@ValueDate", valueDate);
                command.Parameters.AddWithValue("@CostCenterId", costCenterId);
                command.Parameters.AddWithValue("@ReferenceNumber", referenceNumber);
                command.Parameters.AddWithValue("@StatementReference", statementReference);

                command.Parameters.AddWithValue("@IsCredit", stockMaster.IsCredit);

                if (stockMaster.PaymentTermId.Equals(0))
                {
                    command.Parameters.AddWithValue("@PaymentTermId", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@PaymentTermId", stockMaster.PaymentTermId);
                }

                command.Parameters.AddWithValue("@PartyCode", stockMaster.PartyCode);
                command.Parameters.AddWithValue("@PriceTypeId", stockMaster.PriceTypeId);
                command.Parameters.AddWithValue("@SalespersonId", stockMaster.SalespersonId);
                command.Parameters.AddWithValue("@ShipperId", stockMaster.ShipperId);
                command.Parameters.AddWithValue("@ShippingAddressCode", stockMaster.ShippingAddressCode);
                command.Parameters.AddWithValue("@StoreId", stockMaster.StoreId);
                command.Parameters.AddWithValue("@NonTaxable", nonTaxable);

                command.Parameters.AddRange(StockMasterDetailHelper.AddStockMasterDetailParameter(details).ToArray());
                command.Parameters.AddRange(AttachmentHelper.AddAttachmentParameter(attachments).ToArray());

                long tranId = Conversion.TryCastLong(DbOperation.GetScalarValue(command));
                return(tranId);
            }
        }
示例#27
0
        internal static long Add(string catalog, string book, DateTime valueDate, int officeId, int userId, long loginId, string referenceNumber, string statementReference, StockMaster stockMaster, Collection <StockDetail> details, Collection <long> transactionIdCollection, Collection <Attachment> attachments, bool nonTaxable)
        {
            if (stockMaster == null)
            {
                return(0);
            }

            if (details == null)
            {
                return(0);
            }

            if (details.Count.Equals(0))
            {
                return(0);
            }

            string tranIds    = ParameterHelper.CreateBigintArrayParameter(transactionIdCollection, "bigint", "@TranId");
            string detail     = StockMasterDetailHelper.CreateStockMasterDetailParameter(details);
            string attachment = AttachmentHelper.CreateAttachmentModelParameter(attachments);

            string sql = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM transactions.post_non_gl_transaction(@Book::national character varying(48), @OfficeId::integer, @UserId::integer, @LoginId::bigint, @ValueDate::date, @ReferenceNumber::national character varying(24), @StatementReference::text, @PartyCode::national character varying(12), @PriceTypeId::integer, @NonTaxable::boolean,@SalesPersonId::integer, @ShipperId::integer, @ShippingAddressCode::national character varying(12), @StoreId::integer, ARRAY[{0}]::bigint[], ARRAY[{1}], ARRAY[{2}]);", tranIds, detail, attachment);

            using (NpgsqlCommand command = new NpgsqlCommand(sql))
            {
                command.Parameters.AddWithValue("@Book", book);
                command.Parameters.AddWithValue("@OfficeId", officeId);
                command.Parameters.AddWithValue("@UserId", userId);
                command.Parameters.AddWithValue("@LoginId", loginId);
                command.Parameters.AddWithValue("@ValueDate", valueDate);
                command.Parameters.AddWithValue("@ReferenceNumber", referenceNumber);
                command.Parameters.AddWithValue("@StatementReference", statementReference);
                command.Parameters.AddWithValue("@PartyCode", stockMaster.PartyCode);

                if (stockMaster.PriceTypeId.Equals(0))
                {
                    command.Parameters.AddWithValue("@PriceTypeId", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@PriceTypeId", stockMaster.PriceTypeId);
                }

                command.Parameters.AddWithValue("@NonTaxable", nonTaxable);
                command.Parameters.AddWithValue("@SalesPersonId", stockMaster.SalespersonId);
                command.Parameters.AddWithValue("@ShipperId", stockMaster.ShipperId);
                command.Parameters.AddWithValue("@ShippingAddressCode", stockMaster.ShippingAddressCode);
                command.Parameters.AddWithValue("@StoreId", stockMaster.StoreId);

                command.Parameters.AddRange(ParameterHelper.AddBigintArrayParameter(transactionIdCollection, "@TranId").ToArray());
                command.Parameters.AddRange(StockMasterDetailHelper.AddStockMasterDetailParameter(details).ToArray());
                command.Parameters.AddRange(AttachmentHelper.AddAttachmentParameter(attachments).ToArray());

                long tranId = Conversion.TryCastLong(DbOperation.GetScalarValue(catalog, command));
                return(tranId);
            }
        }
示例#28
0
        public int InsertDetailsRecord(ref StockMaster Entity_StockMaster, out string strError)
        {
            int iInsert = 0;

            strError = string.Empty;
            try
            {
                SqlParameter pAction = new SqlParameter(StockMaster._Action, SqlDbType.BigInt);

                SqlParameter pOutwardId       = new SqlParameter(StockMaster._OutwardId, SqlDbType.BigInt);
                SqlParameter pInwardId        = new SqlParameter(StockMaster._InwardId, SqlDbType.BigInt);
                SqlParameter pItemId          = new SqlParameter(StockMaster._ItemId, SqlDbType.BigInt);
                SqlParameter pInwardQty       = new SqlParameter(StockMaster._InwardQty, SqlDbType.Decimal);
                SqlParameter pOutwardQty      = new SqlParameter(StockMaster._OutwardQty, SqlDbType.Decimal);
                SqlParameter pPendingQty      = new SqlParameter(StockMaster._PendingQty, SqlDbType.Decimal);
                SqlParameter pLocationId      = new SqlParameter(StockMaster._LocationId, SqlDbType.BigInt);
                SqlParameter pStockLocationId = new SqlParameter(StockMaster._StockLocationId, SqlDbType.BigInt);
                SqlParameter pRate            = new SqlParameter(StockMaster._Rate, SqlDbType.Decimal);
                SqlParameter pAmount          = new SqlParameter(StockMaster._Amount, SqlDbType.Decimal);
                SqlParameter pUnitConversion  = new SqlParameter(StockMaster._UnitConvDtlsId, SqlDbType.BigInt);
                SqlParameter pItemDetailsId   = new SqlParameter(StockMaster._ItemDetailsId, SqlDbType.BigInt);
                SqlParameter pItemDesc        = new SqlParameter(StockMaster._ItemDesc, SqlDbType.NVarChar);

                pAction.Value          = 8;
                pOutwardId.Value       = Entity_StockMaster.OutwardId;
                pInwardId.Value        = Entity_StockMaster.InwardId;
                pItemId.Value          = Entity_StockMaster.ItemId;
                pInwardQty.Value       = Entity_StockMaster.InwardQty;
                pOutwardQty.Value      = Entity_StockMaster.OutwardQty;
                pPendingQty.Value      = Entity_StockMaster.PendingQty;
                pLocationId.Value      = Entity_StockMaster.LocationId;
                pStockLocationId.Value = Entity_StockMaster.StockLocationID;
                pRate.Value            = Entity_StockMaster.Rate;
                pAmount.Value          = Entity_StockMaster.Amount;
                pUnitConversion.Value  = Entity_StockMaster.UnitConvDtlsId;
                pItemDetailsId.Value   = Entity_StockMaster.ItemDetailsId;
                pItemDesc.Value        = Entity_StockMaster.ItemDesc;

                SqlParameter[] Param = new SqlParameter[] { pAction, pOutwardId, pItemId, pInwardId, pInwardQty, pOutwardQty, pPendingQty, pLocationId, pStockLocationId, pRate, pAmount, pUnitConversion, pItemDetailsId, pItemDesc };

                Open(CONNECTION_STRING);
                BeginTransaction();

                iInsert = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, StockMaster.SP_StockMaster, Param);

                if (iInsert > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                strError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(iInsert);
        }
示例#29
0
        internal static long Add(DateTime valueDate, string book, int officeId, int userId, long loginId, int costCenterId, string referenceNumber, string statementReference, StockMaster stockMaster, Collection <StockDetail> details, Collection <long> transactionIdCollection, Collection <Attachment> attachments)
        {
            if (stockMaster == null)
            {
                return(0);
            }

            if (details == null)
            {
                return(0);
            }

            if (details.Count.Equals(0))
            {
                return(0);
            }

            string tranIds    = ParameterHelper.CreateBigintArrayParameter(transactionIdCollection, "bigint", "@TranId");
            string detail     = StockMasterDetailHelper.CreateStockMasterDetailParameter(details);
            string attachment = AttachmentHelper.CreateAttachmentModelParameter(attachments);

            string sql = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM transactions.post_purchase(@BookName, @OfficeId, @UserId, @LoginId, @ValueDate, @CostCenterId, @ReferenceNumber, @StatementReference, @IsCredit, @PartyCode, @PriceTypeId, @ShipperId, @StoreId, ARRAY[{0}]::bigint[], ARRAY[{1}], ARRAY[{2}])", tranIds, detail, attachment);

            using (NpgsqlCommand command = new NpgsqlCommand(sql))
            {
                command.Parameters.AddWithValue("@BookName", book);
                command.Parameters.AddWithValue("@OfficeId", officeId);
                command.Parameters.AddWithValue("@UserId", userId);
                command.Parameters.AddWithValue("@LoginId", loginId);
                command.Parameters.AddWithValue("@ValueDate", valueDate);
                command.Parameters.AddWithValue("@CostCenterId", costCenterId);
                command.Parameters.AddWithValue("@ReferenceNumber", referenceNumber);
                command.Parameters.AddWithValue("@StatementReference", statementReference);


                command.Parameters.AddWithValue("@IsCredit", stockMaster.IsCredit);
                command.Parameters.AddWithValue("@PartyCode", stockMaster.PartyCode);

                if (stockMaster.PriceTypeId.Equals(0))
                {
                    command.Parameters.AddWithValue("@PriceTypeId", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@PriceTypeId", stockMaster.PriceTypeId);
                }

                if (stockMaster.ShipperId.Equals(0))
                {
                    command.Parameters.AddWithValue("@ShipperId", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@ShipperId", stockMaster.ShipperId);
                }

                command.Parameters.AddWithValue("@StoreId", stockMaster.StoreId);

                command.Parameters.AddRange(ParameterHelper.AddBigintArrayParameter(transactionIdCollection, "@TranId").ToArray());
                command.Parameters.AddRange(StockMasterDetailHelper.AddStockMasterDetailParameter(details).ToArray());
                command.Parameters.AddRange(AttachmentHelper.AddAttachmentParameter(attachments).ToArray());

                long tranId = Conversion.TryCastLong(DbOperation.GetScalarValue(command));
                return(tranId);
            }
        }
示例#30
0
        private void StockMaster_Click(object sender, RoutedEventArgs e)
        {
            StockMaster stock = new StockMaster();

            stock.ShowDialog();
        }