Пример #1
0
        public Sal_SalesAgreementPrePost AssignSalesItemAndSave(FormCollection fCollection, List <PackageDetails> lstPackageDetails, LoginHelper objLoginHelper)
        {
            int    modelCounter = 0, serialCounter = 0;
            string itemCode = string.Empty, modelCode = string.Empty;
            byte   storeLocation     = 1;
            byte   warrantyInMonth   = 0;
            double itemFixedQuantity = 0;

            Sal_SalesAgreementPrePost objSalesAgreement = new Sal_SalesAgreementPrePost();
            Sal_CustomerPrePost       objCustomer       = new Sal_CustomerPrePost();

            Sal_SalesItemsPrePost                    objSalesItem;
            Sal_SalesItemsWithSerialNoPrePost        objItemSalesWithSerialNo;
            List <Inv_ItemMaster>                    lstItemMaster      = new List <Inv_ItemMaster>();
            List <Sal_SalesItemsWithSerialNoPrePost> lstItemWithSerials = new List <Sal_SalesItemsWithSerialNoPrePost>();
            List <Sal_SalesItemsPrePost>             lstSalesItem       = new List <Sal_SalesItemsPrePost>();

            try
            {
                objCustomer       = this.AssignCustomerInfo(fCollection, objLoginHelper);
                objSalesAgreement = this.AssignSalesAgreement(fCollection, lstPackageDetails);

                string[] packageComponents = fCollection["hfStockLocationWiseComponenet"].Split('#');

                lstItemMaster = erpService.ReadItemMaster();

                foreach (PackageDetails pkgd in lstPackageDetails)
                {
                    objSalesItem = new Sal_SalesItemsPrePost();
                    objSalesItem.CustomerCode  = fCollection["hfCustomerCode"].Trim();
                    objSalesItem.CompSeqNo     = pkgd.CompSeqNo;
                    objSalesItem.ItemCategory  = pkgd.ItemCategoryID;
                    objSalesItem.ItemCapacity  = pkgd.ItemCapacity;
                    objSalesItem.UnitOfMeasure = pkgd.UnitOfMeasure;

                    if (pkgd.IsShowInSalesAgreementPage == true)
                    {
                        string[] componentStoreLocation = packageComponents[serialCounter].Split('_');
                        storeLocation = Convert.ToByte(componentStoreLocation[3].Trim());  // Item Store Location
                        objSalesItem.FromStoreLocation = storeLocation;
                    }


                    //
                    if (pkgd.IsItAWarrantyItem == true)
                    {
                        string[] componentStoreLocation = packageComponents[serialCounter].Split('_');
                        warrantyInMonth = Convert.ToByte(componentStoreLocation[5].Trim());  // warrenty
                        objSalesItem.WarrantyInMonth = warrantyInMonth;
                    }

                    //



                    string[] orderDetails = packageComponents[modelCounter].Split('_');

                    if (!string.IsNullOrEmpty(orderDetails[4].Trim()))
                    {
                        objSalesItem.ItemQuantity = Convert.ToDouble(orderDetails[4]);
                    }

                    if (pkgd.IsShowInSalesAgreementPage == true && pkgd.ItemModel.Trim() == "")
                    {
                        // string[] componentsDeatils = packageComponents[modelCounter].Split('_');

                        if (orderDetails[0] == pkgd.ItemCategoryID)   //componentsDeatils[0]
                        {
                            objSalesItem.ItemModel = orderDetails[1]; // componentsDeatils[1];  // Item Model
                        }
                        modelCode = objSalesItem.ItemModel;

                        modelCounter++;
                    }
                    else
                    {
                        if (pkgd.ItemModel.Trim() != "")
                        {
                            objSalesItem.ItemModel = pkgd.ItemModel;
                            modelCode = objSalesItem.ItemModel;
                        }
                        else
                        {
                            objSalesItem.ItemModel = null;
                            modelCode = string.Empty;
                        }
                        modelCounter++;
                    }

                    if (modelCode != string.Empty)
                    {
                        if (pkgd.ItemCapacity.Trim() == "NULL" || pkgd.ItemCapacity.Trim() == "")
                        {
                            var vIt = (from itc in lstItemMaster where itc.ItemCategory == pkgd.ItemCategoryID && itc.ItemCapacity == null && itc.ItemModel == objSalesItem.ItemModel select itc.ItemCode).FirstOrDefault();
                            objSalesItem.ItemCode = vIt.ToString();
                        }
                        else
                        {
                            var vIt = (from itc in lstItemMaster where itc.ItemCategory == pkgd.ItemCategoryID && itc.ItemCapacity == pkgd.ItemCapacity && itc.ItemModel == objSalesItem.ItemModel select itc.ItemCode).FirstOrDefault();
                            objSalesItem.ItemCode = vIt.ToString();
                        }
                    }
                    else
                    {
                        if (pkgd.ItemCapacity.Trim() == "NULL" || pkgd.ItemCapacity.Trim() == "")
                        {
                            var vIt = (from itc in lstItemMaster where itc.ItemCategory == pkgd.ItemCategoryID && itc.ItemCapacity == null && itc.ItemModel == null select itc.ItemCode).FirstOrDefault();
                            objSalesItem.ItemCode = vIt.ToString();
                        }
                        else
                        {
                            var vIt = (from itc in lstItemMaster where itc.ItemCategory == pkgd.ItemCategoryID && itc.ItemCapacity == pkgd.ItemCapacity && itc.ItemModel == null select itc.ItemCode).FirstOrDefault();
                            objSalesItem.ItemCode = vIt.ToString();
                        }
                    }

                    objSalesItem.UnitCost = (from itc in lstItemMaster where itc.ItemCode == objSalesItem.ItemCode select itc.AverageUnitCost).FirstOrDefault();

                    if (pkgd.IsShowInSalesAgreementPage == true && pkgd.IsSerialNoMandatory == true)
                    {
                        string[] componentsDeatils = packageComponents[serialCounter].Split('_');

                        objItemSalesWithSerialNo = new Sal_SalesItemsWithSerialNoPrePost();

                        objItemSalesWithSerialNo.CustomerCode     = fCollection["hfCustomerCode"];
                        objItemSalesWithSerialNo.CompSeqNo        = pkgd.CompSeqNo;
                        objItemSalesWithSerialNo.ItemSerialNo     = componentsDeatils[2].Trim();
                        objItemSalesWithSerialNo.Status           = Helper.Active;
                        objItemSalesWithSerialNo.ItemCode         = objSalesItem.ItemCode;
                        objItemSalesWithSerialNo.RefStoreLocation = storeLocation;  // Item Store Location
                        objItemSalesWithSerialNo.RefLocationCode  = objLoginHelper.LocationCode;

                        lstItemWithSerials.Add(objItemSalesWithSerialNo);

                        //if (!string.IsNullOrEmpty(serialTempTableRows))
                        //    serialTempTableRows += "," + "(" + objSalesItem.ItemCode + ",'" + objItemSalesWithSerialNo.ItemSerialNo + "','" + pkgd.ItemCategoryID + "'," + Convert.ToByte(objItemSalesWithSerialNo.RefStoreLocation) + ",'" + objLoginHelper.LocationCode + "','" + fCollection["hfCustomerCode"].Trim() + "')";
                        //else
                        //    serialTempTableRows = "(" + objSalesItem.ItemCode + ",'" + objItemSalesWithSerialNo.ItemSerialNo + "','" + pkgd.ItemCategoryID + "'," + Convert.ToByte(objItemSalesWithSerialNo.RefStoreLocation) + ",'" + objLoginHelper.LocationCode + "','" + fCollection["hfCustomerCode"].Trim() + "')";
                    }

                    serialCounter++;
                    lstSalesItem.Add(objSalesItem);
                }

                objSalesAgreement = erpService.CreateSalesAgreement(objCustomer, objSalesAgreement, lstSalesItem, lstItemWithSerials);
            }
            catch (Exception ex)
            {
                throw;
            }

            return(objSalesAgreement);
        }
Пример #2
0
        public Sal_CustomerPrePost AssignCustomerInfo(FormCollection fCollection, LoginHelper objLoginHelper)
        {
            try
            {
                Sal_CustomerPrePost objCustomer = new Sal_CustomerPrePost();

                objCustomer.CustomerCode         = fCollection["hfCustomerCode"];
                objCustomer.CustomerName         = fCollection["txtCustomerName"];
                objCustomer.FathersOrHusbandName = fCollection["txtFatherHusbandName"];
                objCustomer.MothersName          = fCollection["txtMotherName"];
                objCustomer.Gender         = fCollection["ddlGender"];
                objCustomer.NationalIDCard = fCollection["txtNationalIdNumber"];
                objCustomer.PhoneNo        = fCollection["txtMobileNumber"];
                objCustomer.Village        = fCollection["txtVillage"];
                objCustomer.PostOffice     = fCollection["txtPostOffice"];
                objCustomer.ThanaID        = fCollection["ddlUpazillaThana"];
                objCustomer.DistrictCode   = erpService.ReadUpazillaByID(fCollection["ddlUpazillaThana"]).DIST_CODE;
                objCustomer.UnitCode       = objLoginHelper.LogInForUnitCode;
                objCustomer.CustomerType   = fCollection["ddlCustomerType"];

                objCustomer.Occupation        = string.IsNullOrEmpty(fCollection["ddlOccupation"].Trim()) ? null : fCollection["ddlOccupation"].Trim();
                objCustomer.IncomeRange       = string.IsNullOrEmpty(fCollection["ddlIncomeRange"].Trim()) ? null : fCollection["ddlIncomeRange"].Trim();
                objCustomer.TotalFamilyMember = string.IsNullOrEmpty(fCollection["txtFamilyMember"].Trim()) ? Convert.ToByte(0) : Convert.ToByte(fCollection["txtFamilyMember"].Trim());

                if (!string.IsNullOrEmpty(fCollection["txtWomenMember"].Trim()))
                {
                    objCustomer.WomenInTotalFamilyMember = Convert.ToByte(fCollection["txtWomenMember"].Trim());
                }
                else
                {
                    objCustomer.WomenInTotalFamilyMember = 0;
                }

                if (fCollection["ddlIsConsultedWithWomenMemberForInstallationOfLamps"].Trim() == "0")
                {
                    objCustomer.IsConsultedWithWomenMemberForInstallationOfLamps = false;
                }
                else
                {
                    objCustomer.IsConsultedWithWomenMemberForInstallationOfLamps = true;
                }

                objCustomer.FuelUsedBeforeSHS       = string.IsNullOrEmpty(fCollection["ddlFuelUsedBeforeSHS"].Trim()) ? null : fCollection["ddlFuelUsedBeforeSHS"].Trim();
                objCustomer.FuelConsumptionPerMonth = string.IsNullOrEmpty(fCollection["txtFuelConsumptionPerMonthLitre"].Trim()) ? Convert.ToByte(0) : Convert.ToByte(fCollection["txtFuelConsumptionPerMonthLitre"].Trim());
                objCustomer.RelationWithGuardian    = string.IsNullOrEmpty(fCollection["ddlGurdianRelation"]) ? null : fCollection["ddlGurdianRelation"].Trim();
                objCustomer.UnionID = fCollection["ddlUnion"].Trim();

                objCustomer.CreatedBy = objLoginHelper.LogInID;
                objCustomer.CreatedOn = DateTime.Now;

                if (fCollection["ddlModeOfPayment"].ToLower().Contains("cash"))
                {
                    objCustomer.Status = Helper.CashSalesCustomer;
                }
                else
                {
                    objCustomer.Status = Helper.Active;
                }

                return(objCustomer);
            }
            catch (Exception ex)
            {
                throw;
            }
        }