예제 #1
0
        public int StoreTempPhysicalInventory(tbl_TempMaster tempMaster, tbl_TempDetail tempDetail)
        {
            try
            {
                if (tempMaster.TempMasterID == 0)
                {
                    Context.TempMaster.Insert(tempMaster);
                    Context.TempMaster.Save();
                }

                if (tempMaster.TempMasterID != 0)
                {
                    Context.TempDetail.Insert(tempDetail);
                    Context.TempDetail.Save();
                }
                return(tempMaster.TempMasterID);
            }
            catch (Exception)
            {
                return(0);
            }
        }
예제 #2
0
        public string InsertTempMaterProductionOrder(string MaterialID, string UOM, string Qty, string LocationID, string UserName, string StorageID)
        {
            tbl_Location       Location   = LocationBL.GetByID(LocationID.Trim());
            int                Docid      = Convert.ToInt32(Location.Prod_Order);
            int                cnt        = Docid + 1;
            string             DocumentID = (LocationID + cnt).ToString().Trim();
            List <tbl_Company> Company    = Context.Company.Get().ToList();
            string             CompanyID  = Company.FirstOrDefault().CompanyID;

            string TempMasterID = null;

            try
            {
                tbl_TempMaster TempMasterHeader = new tbl_TempMaster();

                TempMasterHeader = Context.TempMaster.Get(e => e.LocationID == LocationID && e.DocumentID == DocumentID).FirstOrDefault();
                if (TempMasterHeader != null)
                {
                    TempMasterID = TempMasterHeader.TempMasterID.ToString();
                }
                else
                {
                    TempMasterHeader = new tbl_TempMaster();
                }

                if (TempMasterID == string.Empty || TempMasterID == null)
                {
                    TempMasterHeader.DocumentID   = DocumentID;
                    TempMasterHeader.PONumber     = DocumentID;
                    TempMasterHeader.AddDate      = DateTime.Now;
                    TempMasterHeader.CompanyID    = CompanyID;
                    TempMasterHeader.DocumentDate = DateTime.Now;
                    TempMasterHeader.Filter       = "";
                    TempMasterHeader.Filter_Id    = "";
                    TempMasterHeader.LocationID   = LocationID;
                    TempMasterHeader.PostingDate  = DateTime.Now;
                    TempMasterHeader.StorageID    = StorageID;
                    TempMasterHeader.Type         = "PDO";
                    TempMasterHeader.UserID       = UserName;
                    TempMasterHeader.DocDetail    = "Production Order";
                    Context.TempMaster.Insert(TempMasterHeader);
                    Context.TempMaster.Save();
                }

                TempMasterHeader = Context.TempMaster.Get(e => e.LocationID == LocationID && e.DocumentID == DocumentID).FirstOrDefault();
                if (TempMasterHeader != null)
                {
                    TempMasterID = TempMasterHeader.TempMasterID.ToString();
                    StorageID    = TempMasterHeader.StorageID.ToString();
                }

                tbl_TempDetail TempDetail = new tbl_TempDetail();
                TempDetail.MaterialID   = MaterialID;
                TempDetail.UOM          = UOM;
                TempDetail.AddDate      = DateTime.Now;
                TempDetail.BaseQty      = Convert.ToDecimal(Qty);
                TempDetail.CategoryID   = "";
                TempDetail.CompanyID    = CompanyID;
                TempDetail.DocumentDate = DateTime.Now;
                TempDetail.DocumentID   = DocumentID;
                TempDetail.LocationID   = LocationID;
                TempDetail.PostingDate  = DateTime.Now;
                if (StorageID == null)
                {
                }
                else
                {
                    TempDetail.StorageID = StorageID;
                }

                TempDetail.TranQty      = Convert.ToDecimal(Qty);
                TempDetail.UpdDate      = DateTime.Now;
                TempDetail.UserID       = UserName;
                TempDetail.TempMasterID = Convert.ToInt32(TempMasterID);
                TempDetail.CreditQty    = 0.00M;
                TempDetail.Cost         = 0.00M;
                TempDetail.DiscountRate = 0.00M;
                TempDetail.Amount       = 0.00M;
                TempDetail.CreditAmount = 0.00M;
                TempDetail.OrderQty     = 0.00M;
                TempDetail.Type         = "PDO";

                List <tbl_TempDetail> CheckTempDetails = Context.TempDetail.Get(e => e.LocationID == LocationID && e.MaterialID == MaterialID && e.UOM == UOM).ToList();

                if (CheckTempDetails.Count >= 1)
                {
                    TempDetail         = CheckTempDetails.FirstOrDefault();
                    TempDetail.TranQty = Convert.ToDecimal(Qty) + CheckTempDetails.FirstOrDefault().TranQty;
                    TempDetail.BaseQty = TempDetail.TranQty;

                    Context.TempDetail.Update(TempDetail);
                    Context.tempDetail.Save();
                }
                else
                {
                    Context.TempDetail.Insert(TempDetail);
                    Context.TempDetail.Save();
                }
            }
            catch (Exception ex)
            {
            }
            return(TempMasterID);
        }