예제 #1
0
        public PurchaseReqVM SavePurchaseOrder(PurchaseReqVM purchaseReq)
        {
            if (!purchaseReq.IsEditMode)
            {
                purchaseReq.MRCode = _CodeRep.GetCode(purchaseReq.CmpyCode, "MR");
            }

            return(_purchaseRepo.SavePurchaseOrder(purchaseReq));
        }
예제 #2
0
        public ActionResult SavePurchaseOrder(PurchaseReqVM purchaseOrder)
        {
            List <SessionListnew> list = Session["SesDet"] as List <SessionListnew>;

            if (list == null)
            {
                return(Redirect("Login/InLogin"));
            }
            else
            {
                purchaseOrder.CmpyCode = list[0].CmpyCode;
                return(Json(_purchaseService.SavePurchaseOrder(purchaseOrder), JsonRequestBehavior.AllowGet));
            }
        }
예제 #3
0
        public PurchaseReqVM GetPOMasterDetailsEdit(string CmpyCode, string MRCode)
        {
            ds = _EzBusinessHelper.ExecuteDataSet("Select * from PMMRH001 where CmpyCode='" + CmpyCode + "' and MRCode='" + MRCode + "' ");

            dt = ds.Tables[0];
            PurchaseReqVM pr = new PurchaseReqVM();

            foreach (DataRow dr in dt.Rows)
            {
                pr.CmpyCode     = dr["CmpyCode"].ToString();
                pr.MRCode       = dr["MRCode"].ToString();
                pr.Description  = dr["Description"].ToString();
                pr.LocationCode = dr["LocCode"].ToString();
                pr.PODate       = Convert.ToDateTime(dr["Dates"].ToString());
                //pr.PODate = Convert.ToDateTime(DateTime.ParseExact(dr["Dates"].ToString(), "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture));
                pr.PreparedBy    = dr["PreparedBy"].ToString();
                pr.ProjectCode   = dr["ProjectCode"].ToString();
                pr.RequesterCode = dr["EmpCode"].ToString();
                pr.ResourceType  = dr["ResourceType"].ToString();
            }
            return(pr);
        }
예제 #4
0
        public PurchaseReqVM SavePurchaseOrder(PurchaseReqVM po)
        {
            int    n;
            string dtstr   = null;
            var    counter = 1;

            if (!po.IsEditMode)
            {
                try
                {
                    MReqHeader pt  = new MReqHeader();
                    int        pno = _EzBusinessHelper.ExecuteScalar("Select Nos from PARTTBL001 where CmpyCode='" + po.CmpyCode + "' and Code='" + PurchaseMgmtConstants.MRHeader + "' ");

                    //ds = _EzBusinessHelper.ExecuteDataSet("Select * from PARTTBL001 where CmpyCode='" + po.CmpyCode + "' and Code='" + PurchaseMgmtConstants.MRHeader + "' ");
                    //MReqHeader pt = new MReqHeader();
                    //dt = ds.Tables[0];
                    //int pno = 0;
                    //foreach (DataRow dr in dt.Rows)
                    //{

                    //    pno = Convert.ToInt16(dr["Nos"]) + 1;
                    //}
                    //pt.MRCode = string.Concat(PurchaseMgmtConstants.MRHeader, "-", (Convert.ToInt16(pno)).ToString().PadLeft(4, '0')).ToString();
                    pt.MRCode       = po.MRCode;
                    pt.CmpyCode     = po.CmpyCode;
                    pt.ResourceType = po.ResourceType;
                    DateTime dt1 = Convert.ToDateTime(po.PODate.ToString());
                    dtstr                   = dt1.ToString("yyyy-MM-dd hh:mm:ss tt");
                    pt.Description          = po.Description;
                    pt.EmpCode              = po.RequesterCode;
                    pt.LocCode              = po.LocationCode;
                    pt.ProjectCode          = po.ProjectCode;
                    pt.ApprovalYN           = PurchaseMgmtConstants.ApprovalYN;
                    pt.MRFrom               = PurchaseMgmtConstants.MRFrom;
                    pt.Status               = PurchaseMgmtConstants.Status;
                    pt.DontShowJobInList    = 0;
                    pt.GenerateInquiry      = string.Empty;
                    pt.IsPopUpCheckedByUser = 0;
                    pt.JobNo                = string.Empty;
                    pt.PreparedBy           = "EASY";
                    pt.Priority             = "N";
                    pt.RType                = string.Empty;
                    pt.WONo                 = string.Empty;
                    List <MReqDetail> ObjList = new List <MReqDetail>();
                    ObjList.AddRange(po.PurchaseOrderDetails.Select(m => new MReqDetail
                    {
                        CmpyCode      = po.CmpyCode,
                        MRCode        = pt.MRCode, //response.MRCode,
                        Description   = m.Description,
                        BaseQtyReq    = 1,
                        BaseUnitQty   = m.Quantity,
                        BOQSno        = 1,
                        Specification = m.Specification ?? string.Empty,
                        SNo           = counter++,
                        ItemCode      = m.ItemCode,
                        Unit          = m.Unit,
                        Qty           = m.Quantity,
                        CostCode      = string.Empty,
                        FileType      = string.Empty,
                        ImgDesc       = string.Empty,
                        OverBudget    = 0,
                        PackageSno    = 0,
                        PartNumber    = string.Empty,
                        Product_Img   = new byte[1],
                        QtyReceived   = 0,
                        Select_Img    = string.Empty
                    }).ToList());
                    using (TransactionScope scope1 = new TransactionScope())
                    {
                        _EzBusinessHelper.ExecuteNonQuery("insert into PMMRH001(MRCode,CmpyCode,ResourceType,Dates,Description,EmpCode,LocCode,ProjectCode,ApprovalYN,MRFrom,Status,DontShowJobInList,GenerateInquiry,IsPopUpCheckedByUser,JobNo,PreparedBy,Priority,RType,WONo) values('" + pt.MRCode + "','" + pt.CmpyCode + "','" + pt.ResourceType + "','" + dtstr + "','" + pt.Description + "','" + pt.EmpCode + "','" + pt.LocCode + "','" + pt.ProjectCode + "','" + pt.ApprovalYN + "','" + pt.MRFrom + "','" + pt.Status + "','" + pt.DontShowJobInList + "','" + pt.GenerateInquiry + "','" + pt.IsPopUpCheckedByUser + "','" + pt.JobNo + "','" + pt.PreparedBy + "','" + pt.Priority + "','" + pt.RType + "','" + pt.WONo + "')");
                        n = ObjList.Count;
                        while (n > 0)
                        {
                            _EzBusinessHelper.ExecuteNonQuery("insert into PMMRD002(CmpyCode,MRCode,Description,BaseQtyReq,BaseUnitQty,BOQSno,Specification,SNo,ItemCode,Unit,Qty,CostCode,FileType,ImgDesc,OverBudget,PackageSno,PartNumber,Product_Img,QtyReceived,Select_Img) values('" + ObjList[n - 1].CmpyCode.ToString() + "','" + ObjList[n - 1].MRCode.ToString() + "','" + ObjList[n - 1].Description.ToString() + "','" + ObjList[n - 1].BaseQtyReq.ToString() + "','" + ObjList[n - 1].BaseUnitQty.ToString() + "','" + ObjList[n - 1].BOQSno.ToString() + "', '" + ObjList[n - 1].Specification.ToString() + "','" + ObjList[n - 1].SNo.ToString() + "','" + ObjList[n - 1].ItemCode.ToString() + "','" + ObjList[n - 1].Unit.ToString() + "','" + ObjList[n - 1].Qty.ToString() + "','" + ObjList[n - 1].CostCode.ToString() + "','" + ObjList[n - 1].FileType.ToString() + "','" + ObjList[n - 1].ImgDesc.ToString() + "','" + ObjList[n - 1].OverBudget.ToString() + "','" + ObjList[n - 1].PackageSno.ToString() + "','" + ObjList[n - 1].PartNumber.ToString() + "','" + ObjList[n - 1].Product_Img.ToString() + "','" + ObjList[n - 1].QtyReceived.ToString() + "','" + ObjList[n - 1].Select_Img.ToString() + "')");
                            n = n - 1;
                        }
                        _EzBusinessHelper.ExecuteNonQuery(" UPDATE PARTTBL001 SET Nos = " + (pno + 1) + " where CmpyCode='" + po.CmpyCode + "' and Code='" + PurchaseMgmtConstants.MRHeader + "'");
                        counter         = 1;
                        po.ErrorMessage = string.Empty;
                        po.IsSavedFlag  = true;
                        scope1.Complete();
                    }
                }
                catch (Exception)
                {
                    po.ErrorMessage = "Error occur";
                    po.IsSavedFlag  = false;
                }
            }
            else
            {
                MReqHeader pt = new MReqHeader();
                try
                {
                    DateTime dt = Convert.ToDateTime(po.PODate.ToString());
                    dtstr           = dt.ToString("yyyy-MM-dd hh:mm:ss tt");
                    pt.Description  = po.Description;
                    pt.EmpCode      = po.RequesterCode;
                    pt.LocCode      = po.LocationCode;
                    pt.ResourceType = po.ResourceType;
                    pt.MRCode       = po.MRCode;
                    pt.CmpyCode     = po.CmpyCode;
                    pt.ProjectCode  = po.ProjectCode;
                    using (TransactionScope scope1 = new TransactionScope())
                    {
                        _EzBusinessHelper.ExecuteNonQuery("Delete from PMMRD002 where MRCode= '" + pt.MRCode + "' and CmpyCode='" + pt.CmpyCode + "' ");
                        _EzBusinessHelper.ExecuteNonQuery("Delete from PMMRH001 where MRCode= '" + pt.MRCode + "' and CmpyCode='" + pt.CmpyCode + "' ");
                        List <MReqDetail> ObjList = new List <MReqDetail>();
                        ObjList.AddRange(po.PurchaseOrderDetails.Select(m => new MReqDetail
                        {
                            CmpyCode      = po.CmpyCode,
                            MRCode        = po.MRCode,
                            Description   = m.Description,
                            BaseQtyReq    = 1,
                            BaseUnitQty   = m.Quantity,
                            BOQSno        = 1,
                            Specification = m.Specification ?? string.Empty,
                            SNo           = counter++,
                            ItemCode      = m.ItemCode,
                            Unit          = m.Unit,
                            Qty           = m.Quantity,
                            CostCode      = string.Empty,
                            FileType      = string.Empty,
                            ImgDesc       = string.Empty,
                            OverBudget    = 0,
                            PackageSno    = 0,
                            PartNumber    = string.Empty,
                            Product_Img   = new byte[1],
                            QtyReceived   = 0,
                            Select_Img    = string.Empty
                        }).ToList());
                        _EzBusinessHelper.ExecuteNonQuery("insert into PMMRH001(MRCode,CmpyCode,ResourceType,Dates,Description,EmpCode,LocCode,ProjectCode,ApprovalYN,MRFrom,Status,DontShowJobInList,GenerateInquiry,IsPopUpCheckedByUser,JobNo,PreparedBy,Priority,RType,WONo) values('" + pt.MRCode + "','" + pt.CmpyCode + "','" + pt.ResourceType + "','" + dtstr + "','" + pt.Description + "','" + pt.EmpCode + "','" + pt.LocCode + "','" + pt.ProjectCode + "','" + pt.ApprovalYN + "','" + pt.MRFrom + "','" + pt.Status + "','" + pt.DontShowJobInList + "','" + pt.GenerateInquiry + "','" + pt.IsPopUpCheckedByUser + "','" + pt.JobNo + "','" + pt.PreparedBy + "','" + pt.Priority + "','" + pt.RType + "','" + pt.WONo + "')");
                        n = ObjList.Count;
                        while (n > 0)
                        {
                            string str = ObjList[n - 1].CmpyCode.ToString();
                            _EzBusinessHelper.ExecuteNonQuery("insert into PMMRD002(CmpyCode,MRCode,Description,BaseQtyReq,BaseUnitQty,BOQSno,Specification,SNo,ItemCode,Unit,Qty,CostCode,FileType,ImgDesc,OverBudget,PackageSno,PartNumber,Product_Img,QtyReceived,Select_Img) values('" + ObjList[n - 1].CmpyCode.ToString() + "','" + ObjList[n - 1].MRCode.ToString() + "','" + ObjList[n - 1].Description.ToString() + "','" + ObjList[n - 1].BaseQtyReq.ToString() + "','" + ObjList[n - 1].BaseUnitQty.ToString() + "','" + ObjList[n - 1].BOQSno.ToString() + "', '" + ObjList[n - 1].Specification.ToString() + "','" + ObjList[n - 1].SNo.ToString() + "','" + ObjList[n - 1].ItemCode.ToString() + "','" + ObjList[n - 1].Unit.ToString() + "','" + ObjList[n - 1].Qty.ToString() + "','" + ObjList[n - 1].CostCode.ToString() + "','" + ObjList[n - 1].FileType.ToString() + "','" + ObjList[n - 1].ImgDesc.ToString() + "','" + ObjList[n - 1].OverBudget.ToString() + "','" + ObjList[n - 1].PackageSno.ToString() + "','" + ObjList[n - 1].PartNumber.ToString() + "','" + ObjList[n - 1].Product_Img.ToString() + "','" + ObjList[n - 1].QtyReceived.ToString() + "','" + ObjList[n - 1].Select_Img.ToString() + "')");
                            n = n - 1;
                        }
                        scope1.Complete();
                        po.ErrorMessage = string.Empty;
                        po.IsSavedFlag  = true;
                    }
                }
                catch (Exception ex)
                {
                    po.ErrorMessage = "Error occur";
                    po.IsSavedFlag  = false;
                }
            }
            return(po);
        }