コード例 #1
0
        public ActionResult SaveSalesOrder(SlsSalesOrderViewModel objT)
        {
            int userId = Convert.ToInt32(Session["userId"]);
            int companyId = Convert.ToInt32(Session["companyId"]);
            int employeeId = Convert.ToInt32(Session["employeeId"]);

            HrmEmployee employee = _hrmEmployeeService.GetById(employeeId);

            Operation objOperation = new Operation { Success = false };

            if (ModelState.IsValid)
            {
                if (objT.Id == 0)
                {
                    if ((bool)Session["Add"])
                    {
                        //objT.Status = 0;
                        objT.SlsOfficeId = employee.SlsOfficeId;
                        objT.HrmEmployeeId = employeeId;
                        objT.SecCompnayId = companyId;
                        objT.CreatedBy = userId;
                        objT.CreatedDate = DateTime.Now.Date;
                        objT.OrderDate = DateTime.Now.Date;

                        //1=Regular,2=Corporate,3=Retail
                        if(objT.SalesType == 3)
                        {
                            //For retail sale - date will be entry date
                            objT.PreferredDeliveryDate = DateTime.Now;
                        }

                        objOperation = _salesOrderService.Save(objT);
                    }
                    else { objOperation.OperationId = -1; }

                }
                else
                {
                    if ((bool)Session["Edit"])
                    {
                        //objT.Status = 0;
                        objT.SlsOfficeId = employee.SlsOfficeId;
                        objT.HrmEmployeeId = employeeId;
                        objT.SecCompnayId = companyId;
                        objT.ModifiedBy = userId;
                        objT.ModifiedDate = DateTime.Now.Date;
                        objOperation = _salesOrderService.Update(objT);
                    }
                    else { objOperation.OperationId = -2; }
                }
            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }
コード例 #2
0
        public ActionResult SaveSalesOrderFromAndriod(SlsSalesOrderViewModel objT)
        {
            var memstream = new MemoryStream();
            Request.InputStream.Position = 0;
            Request.InputStream.CopyTo(memstream);
            memstream.Position = 0;
            using (StreamReader reader = new StreamReader(memstream))
            {
                try
                {
                    var text = reader.ReadToEnd();

                    SlsSalesOrderViewModel record = JsonConvert.DeserializeObject<SlsSalesOrderViewModel>(text);
                    if(record!=null)
                    {
                        objT = record;
                    }
                }
                catch(Exception ex)
                { }

            }

            int userId = Convert.ToInt32(Session["userId"]);
            int companyId = Convert.ToInt32(Session["companyId"]);
            int employeeId = Convert.ToInt32(Session["employeeId"]);

            HrmEmployee employee = _hrmEmployeeService.GetById(employeeId);

            Operation objOperation = new Operation { Success = false };

            if (ModelState.IsValid)
            {
                if (objT.Id == 0)
                {

                    //objT.Status = 0;
                    objT.RefNo = this.GetRefNo(companyId, employeeId);
                    objT.SlsOfficeId = employee.SlsOfficeId;
                    objT.HrmEmployeeId = employeeId;
                    objT.SecCompnayId = companyId;
                    objT.CreatedBy = userId;
                    objT.CreatedDate = DateTime.Now.Date;
                    objT.OrderDate = DateTime.Now.Date;

                    //1=Regular,2=Corporate,3=Retail
                    if (objT.SalesType == 3)
                    {
                        //For retail sale - date will be entry date
                        objT.PreferredDeliveryDate = DateTime.Now;
                    }

                    objOperation = _salesOrderService.Save(objT);

                }

            }
            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }
コード例 #3
0
        public ActionResult SaveSalesDeliveryInternal(SlsSalesOrderViewModel objS)
        {
            int soId = objS.Id;
            decimal discount = objS.Discount;
            decimal total = objS.Total;

            SlsDeliveryViewModel objT = new SlsDeliveryViewModel();

            int userId = Convert.ToInt32(Session["userId"]);
            int companyId = Convert.ToInt32(Session["companyId"]);
            int employeeId = Convert.ToInt32(Session["employeeId"]);
            SecCompany objCmnCompany = _SecCompanyService.GetById(companyId);
            SlsOffice office = _officeService.GetById((int)_hrmEmployeeService.GetById(employeeId).SlsOfficeId);
            string challanNo = _DeliveryService.GetChallanNo(objCmnCompany.Prefix, office.Code);
            string invoiceNo = _DeliveryService.GetInvoiceNo(objCmnCompany.Prefix, office.Code);

            Operation objOperation = new Operation { Success = false };

            if (ModelState.IsValid)
            {
                if (objT.Id == 0)
                {
                    if ((bool)Session["Add"])
                    {
                        objT.SlsSalesOrderId = soId;
                        objT.DeliveryDate = DateTime.Now;
                        objT.ChallanNo = challanNo;
                        objT.InvoiceNo = invoiceNo;
                        objT.VehicleNo = "";
                        objT.Remarks = "";
                        objT.Discount = discount;
                        objT.Total = total;
                        objT.ReceivedStatus = 1;
                        objT.ReceivedDate = DateTime.Now;
                        objT.ReceivedRemarks = "";
                        objT.CreatedBy = userId;
                        objT.CreatedDate = DateTime.Now.Date;

                        //map details of sales items to delivery items.
                        IList<SlsDeliverDetailViewModel> details = new List<SlsDeliverDetailViewModel>();

                        foreach(var det in objS.SalesOrderDetails)
                        {
                            SlsDeliverDetailViewModel dObj = new SlsDeliverDetailViewModel();

                            dObj.SlsProductId = det.SlsProductId;
                            dObj.Quantity = det.SalesOrderQuantity;
                            dObj.SlsUnitId = det.SlsUnitId;
                            dObj.Rate = det.Rate;
                            dObj.Price = det.Price;
                            dObj.Discount = det.Discount;
                            dObj.Total = det.Total;
                            dObj.SalesOrderQuantity = det.SalesOrderQuantity;
                            dObj.SlsProductName = det.SlsProductName;
                            dObj.SlsUnitName = det.SlsUnitName;

                            details.Add(dObj);
                        }

                        objT.SlsDeliverDetails = details;

                        objOperation = _DeliveryService.Save(objT);
                    }
                    else { objOperation.OperationId = -1; }

                }
                else
                {
                    if ((bool)Session["Edit"])
                    {
                        //Normally not required till now - as this will perform once upon a time
                        objT.ModifiedBy = userId;
                        objT.ModifiedDate = DateTime.Now.Date;
                        objOperation = _DeliveryService.Update(objT);
                    }
                    else { objOperation.OperationId = -2; }
                }
            }
            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }