private bool IsWorkorderAmountExceedContractAmountSubProject()
        {
            if (!_isSubProject)
            {
                return(false);                //NA
            }
            double contractAmount = 0;


            //Check if the main project has contract
            Sales_JobMasterList mainProject =
                _db.Sales_JobMasterList.First(x => x.jobNumber == _project.jobTitle && x.subProject == 0);

            if (mainProject != null)
            {
                List <Sales_JobMasterList_QuoteRev> mainContracts = _db.Sales_JobMasterList_QuoteRev.Where(
                    x => x.jobID == mainProject.jobID && x.contractAmount > 0 & x.quoteStatus == 420).ToList();
                if (mainContracts.Any())
                {
                    foreach (Sales_JobMasterList_QuoteRev mainContract in mainContracts)
                    {
                        MyConvert.ConvertToDouble(mainContract.contractAmount);
                    }
                }
            }
            return(false);
        }
示例#2
0
        public void RefreshMaterialID()
        {
            MaterialID = 0;
            var material = _db.Materials.FirstOrDefault(x => CategoryID0 > 0 && x.CategoryID0 == CategoryID0 &&
                                                        (CategoryID1 == 0 || x.CategoryID1 == CategoryID1) &&
                                                        (CategoryID2 == 0 || x.CategoryID2 == CategoryID2) &&
                                                        (CategoryID3 == 0 || x.CategoryID3 == CategoryID3) &&
                                                        (CategoryID4 == 0 || x.CategoryID4 == CategoryID4));

            if (material != null)
            {
                MaterialID = material.MaterialID;

                var mp = _db.MaterialPrices.FirstOrDefault(x => x.MaterialID == MaterialID);
                if (mp == null)
                {
                    return;
                }

                UnitName     = mp.MaterialPriceUnit.UnitName;
                CurrentPrice = string.Format("{0:C2}", mp.Price);
                Price        = MyConvert.ConvertToDouble(mp.Price);
                MaterialName = MaterialCommon.GetMaterialName(material);
            }
        }
示例#3
0
        public virtual void CopyItems(int myParentID, DataSet ds1, DataTable tblItems)
        {
            foreach (DataRow row in tblItems.Rows)
            {
                if (Convert.ToBoolean(row["isFinal"]))
                {
                    DataRow rowNew = ds1.Tables["t1"].NewRow();
                    rowNew["woID"]            = _myParentID;
                    rowNew["estItemID"]       = MyConvert.ConvertToInteger(row["estItemID"]);
                    rowNew["estItemNameText"] = MyConvert.ConvertToString(row["estItemNameText"]);

                    string copyDetails = SalesCenterConfiguration.CopyDetailsToWorkorder;
                    if (copyDetails.Trim().ToLower() == "yes")
                    {
                        rowNew["woDescription"] = MyConvert.ConvertToString(row["Description"]);
                    }
                    else
                    {
                        rowNew["woDescription"] = DBNull.Value;
                    }

                    rowNew["woPrintOrder"]     = MyConvert.ConvertToInteger(row["PrintOrder"]);
                    rowNew["qty"]              = MyConvert.ConvertToInteger(row["qty"]);
                    rowNew["qtyPC"]            = MyConvert.ConvertToInteger(row["qtyPC"]);
                    rowNew["heightFromGround"] = MyConvert.ConvertToString(row["heightFromGround"]);


                    int requirement = MyConvert.ConvertToInteger(row["Requirement"]);
                    if (requirement < 10)
                    {
                        requirement = 10;
                    }
                    rowNew["Requirement"] = requirement;

                    rowNew["Position"] = "Outdoor";
                    if (!Convert.IsDBNull(row["Position"]))
                    {
                        rowNew["Position"] = row["Position"];
                    }

                    rowNew["fromWhere"] = NGenerateTitleFrom.Estimation;

                    rowNew["scHydroInspectionRequired"] = false;
                    rowNew["scPurpose"]  = 0;
                    rowNew["scPurpose1"] = false;
                    rowNew["scPurpose2"] = false;
                    rowNew["scPurpose3"] = false;
                    rowNew["scPurpose4"] = false;

                    //Item ID
                    rowNew["nameDetailsID"] = row["nameDetailsID"];
                    rowNew["qiAmount"]      = MyConvert.ConvertToDouble(row["estimatorPrice"]);
                    string s = "E" + string.Format("{0:D2}", row["SerialID"]);
                    rowNew["SerialID"]        = s;
                    rowNew["BySubcontractor"] = row["BySubcontractor"];
                    ds1.Tables["t1"].Rows.Add(rowNew);
                }
            }
        }
示例#4
0
        private void InitializationProperties(DataRow row)
        {
            if (row == null)
            {
                return;
            }
            JobId = MyConvert.ConvertToInteger(row["jobID"]);

            WorkedHour      = MyConvert.ConvertToDouble(row["workedHour"]);
            FinishedDate    = MyConvert.ConvertToDate(row["FinishedDate"]);
            NumberOfDrawing = MyConvert.ConvertToInteger(row["NumberOfDrawing"]);
            Note            = MyConvert.ConvertToString(row["Note"]);
        }
示例#5
0
        public static string GetMaterialLabel(Model.Material material)
        {
            var    materialPrice = material.MaterialPrices.FirstOrDefault(x => x.Active);
            double price         = 0;
            string unitName      = "na";

            if (materialPrice != null)
            {
                price    = MyConvert.ConvertToDouble(materialPrice.Price);
                unitName = materialPrice.MaterialPriceUnit.UnitName;
            }
            var s = GetMaterialName(material) +
                    "--" +
                    string.Format("{0:C2}", price) +
                    "/" +
                    unitName;

            return(s);
        }
示例#6
0
        private string GetNewValue(object str)
        {
            string s = "";

            if (!MyConvert.IsNullString(str))
            {
                string s1 = Convert.ToString(str);
                //remove '
                while (s1.Contains(","))
                {
                    int int1 = s1.IndexOf(",");
                    s1 = s1.Remove(int1, 1);
                }

                //handle "$"
                try
                {
                    if (s1.Contains("$"))
                    {
                        int int1 = s1.IndexOf("$");
                        s1 = s1.Remove(int1, 1);
                    }
                    double d = MyConvert.ConvertToDouble(s1);
                    if (d != 0)
                    {
                        s1 = "$" + (d * Rate).ToString();
                    }

                    s = s1;
                }
                catch (SqlException ex)
                {
                }
            }


            return(s);
        }
示例#7
0
        //Single Size
        private bool IsSizeValidated(EST_Item_Specification_Size size)
        {
            var b = true;

            if (size.IsWidthMandatory)
            {
                if (MyConvert.ConvertToInteger(size.WidthFeet) == 0 && MyConvert.IsNullString(size.WidthInch))
                {
                    b = false;
                }
            }

            if (size.IsHeightEnabled)
            {
                if (MyConvert.ConvertToInteger(size.WidthFeet) == 0 && MyConvert.IsNullString(size.WidthInch))
                {
                    b = false;
                }
            }

            if (size.IsThicknessEnabled)
            {
                if (MyConvert.ConvertToInteger(size.HeightFeet) == 0 && MyConvert.IsNullString(size.HeightInch))
                {
                    b = false;
                }
            }

            if (size.IsPcEnabled)
            {
                if (MyConvert.ConvertToDouble(size.Pc) < 1)
                {
                    b = false;
                }
            }
            return(b);
        }
示例#8
0
        public void Generate()
        {
            DataTable tbl = EstItemCommon.GetEstimationItems(_estRevID);

            if (tbl != null)
            {
                //
                //2. Define the destination: InvoiceItem
                var connectionSQL = new SqlConnection(SalesCenterConfiguration.ConnectionString);

                const string sqlSelectString2 = "SELECT *  FROM [Invoice_Item] WHERE ([quoteItemID] = 0) ";
                var          selectCommand2   = new SqlCommand(sqlSelectString2, connectionSQL);
                var          adapter2         = new SqlDataAdapter(selectCommand2);

                var ds2 = new DataSet();
                ds2.Tables.Clear();

                try
                {
                    connectionSQL.Open();
                    //define row
                    adapter2.Fill(ds2, "t2");

                    foreach (DataRow row in tbl.Rows)
                    {
                        DataRow rowNew = ds2.Tables["t2"].NewRow();

                        rowNew["quoteRevID"] = _invoiceID;

                        int fwJobTypeRequriedmentID = Convert.ToInt32(row["RequirementID"]);
                        var sp = new SupplyType(fwJobTypeRequriedmentID);
                        rowNew["supplyType"] = sp.QuoteSupplyTypeID;

                        rowNew["qiPrintOrder"] = row["estItemNo"];
                        rowNew["quoteOption"]  = row["ItemOption"];
                        rowNew["isFinal"]      = row["isFinalOption"];
                        rowNew["estItemID"]    = row["estItemID"];
                        rowNew["qiItemTitle"]  = row["ProductName"];


                        string copyDetails = SalesCenterConfiguration.CopyDetailsToInvoice;
                        if (copyDetails.Trim().ToLower() == "yes")
                        {
                            rowNew["qiDescription"] = row["Description"];
                        }
                        else
                        {
                            rowNew["qiDescription"] = DBNull.Value;
                        }

                        rowNew["recordType"] = "I";

                        rowNew["qiQty"]   = row["Qty"];
                        rowNew["qiQtyPC"] = row["QtyPc"];


                        double qiAmount = MyConvert.ConvertToDouble(row["estimatorPrice"]);
                        rowNew["qiAmount"]    = qiAmount;
                        rowNew["qiUnitPrice"] = 0;
                        //to be defined in estimation

                        rowNew["estItemID"] = row["estItemID"];

                        rowNew["Requirement"] = row["RequirementID"];
                        //rowNew["Position"] = row["Position"];
                        rowNew["Position"] = "Indoor";

                        int s = MyConvert.ConvertToInteger(row["SerialID"]);
                        rowNew["SerialID"]      = "E" + string.Format("{0:D2}", s);
                        rowNew["nameDetailsID"] = row["ProductID"];
                        ds2.Tables["t2"].Rows.Add(rowNew);
                    }

                    //4. Write ds2,  back to DB

                    var cb = new SqlCommandBuilder(adapter2);
                    adapter2 = cb.DataAdapter;


                    adapter2.Update(ds2, "t2");
                }
                catch (SqlException ex)
                {
                    string errorLog = ex.Message;
                }
                finally
                {
                    connectionSQL.Close();
                }
            }
        }
示例#9
0
        //13227

        /// <summary>
        /// Collumn : Name
        /// Collumn 0: Rate
        /// Collumn 1: SupplyOnly
        /// Collumn 2: Installation
        /// </summary>
        public void Refresh()
        {
            if (CostItems == null)
            {
                return;
            }
            if (!CostItems.Any())
            {
                return;
            }
            //-------------------------------------------------
            //Shop Material Cost=Material +
            var t00 = CostItems.Where(x => x.TypeID == (int)NEstCostType.ShopMaterail).ToList();

            var marterialCostShopOriginal = t00.Count == 0 ? 0 : t00.Sum(x => x.SubTotal);

            marterialCostShopOriginal = marterialCostShopOriginal * CostParameter.Configuration.MarkupShopMaterial;


            marterialCostShopOriginal = marterialCostShopOriginal * CostParameter.Configuration.MaterialWastageRate;

            //Other and Subcontract
            var t00a = CostItems.Where(x => x.TypeID == (int)NEstCostType.ShopOther ||
                                       x.TypeID == (int)NEstCostType.ShopSubcontract)
                       .ToList();
            var materialCostShopSubcontractAndOther = t00a.Count == 0 ? 0 : t00a.Sum(x => x.SubTotal);

            var materialCostShop = (marterialCostShopOriginal + materialCostShopSubcontractAndOther) *
                                   CostParameter.Configuration.MaterialMarkupPercentage;
            var name01 = "Shop Material Cost (x" +
                         MyConvert.ConvertToString(CostParameter.Configuration.MaterialMarkupPercentage) +
                         ")";

            name01 += " (x";
            name01 += MyConvert.ConvertToString(CostParameter.Configuration.MarkupShopMaterial) +
                      ")";

            var summary01 = new CR_Cost_Summary
            {
                Name = name01,

                ProjectID       = CostParameter.ProjectID,
                EstRevID        = CostParameter.EstRevID,
                EstItemID       = CostParameter.EstItemID,
                WorkorderID     = CostParameter.WorkorderID,
                WorkorderItemID = CostParameter.WorkorderItemID,

                OrderNumber = 1,
                Column0     = "",
                Column1     = "",
                Column2     = (materialCostShop).ToString("C0"),
                TypeID      = (int)NEstCostSummaryType.PriceA,
            };


            //-------------------------------------------------
            var t01            = CostItems.Where(x => x.TypeID == (int)NEstCostType.ShopLabour).ToList();
            var labourHourShop = t01.Count == 0 ? 0 : t01.Sum(x => x.Qty);
            var labourCostShop = CostParameter.Configuration.LabourRateShop * labourHourShop;

            var summary02 = new CR_Cost_Summary
            {
                Name = "Shop Labour Cost ($" + Convert.ToString(CostParameter.Configuration.LabourRateShop) + ")",

                ProjectID       = CostParameter.ProjectID,
                EstRevID        = CostParameter.EstRevID,
                EstItemID       = CostParameter.EstItemID,
                WorkorderID     = CostParameter.WorkorderID,
                WorkorderItemID = CostParameter.WorkorderItemID,

                OrderNumber = 2,
                Column0     = "",
                Column1     = "",
                Column2     = (labourCostShop).ToString("C0"),
                TypeID      = (int)NEstCostSummaryType.PriceA,
            };

            //-------------------------------------------------
            var modifyRate       = Convert.ToDouble(CostParameter.Configuration.DiscountRate);
            var modifyRateString = " (" + MyConvert.ConvertDoubleToPercentage(CostParameter.Configuration.DiscountRate) + ")";


            var t0b = CostItems.Where(x => x.TypeID == (int)NEstCostType.ShopStandItem).ToList();
            var shopStandardItem = t0b.Count == 0 ? 0 : t0b.Sum(x => x.SubTotal);

            shopStandardItem = shopStandardItem * CostParameter.Configuration.MarkupStandardItem;
            //
            var name1 = "Supply Only Cost";

            if (Math.Abs(modifyRate - 0) > 0.001)
            {
                name1 += modifyRateString;
            }

            var supplyOnlyCost = (materialCostShop + labourCostShop) * (1 + CostParameter.Configuration.DiscountRate) + shopStandardItem;
            var summary11      = new CR_Cost_Summary
            {
                Name            = name1,
                ProjectID       = CostParameter.ProjectID,
                EstRevID        = CostParameter.EstRevID,
                EstItemID       = CostParameter.EstItemID,
                WorkorderID     = CostParameter.WorkorderID,
                WorkorderItemID = CostParameter.WorkorderItemID,

                OrderNumber = 11,
                Column0     = "",
                Column1     = "",
                Column2     = (supplyOnlyCost).ToString("C0"),
                TypeID      = (int)NEstCostSummaryType.PriceA,
            };

            //-------------------------------------------------
            //Installation
            var t2A             = CostItems.Where(x => x.TypeID == (int)NEstCostType.InstallationTraveling).ToList();
            var travellingHours = t2A.Count == 0 ? 0 : t2A.Sum(x => x.Qty);
            var travellingCost  = MyConvert.ConvertToDouble(travellingHours * CostParameter.Configuration.LabourRateInstallation *
                                                            (1 + CostParameter.Configuration.DiscountRate));

            var summary12Name = "Travelling Cost" + "($" + Convert.ToString(CostParameter.Configuration.LabourRateInstallation) + ")";

            if (Math.Abs(modifyRate - 0) > 0.001)
            {
                summary12Name += modifyRateString;
            }

            var summary12 = new CR_Cost_Summary
            {
                Name            = summary12Name,
                ProjectID       = CostParameter.ProjectID,
                EstRevID        = CostParameter.EstRevID,
                EstItemID       = CostParameter.EstItemID,
                WorkorderID     = CostParameter.WorkorderID,
                WorkorderItemID = CostParameter.WorkorderItemID,

                OrderNumber = 12,
                Column0     = "",
                Column1     = "",
                Column2     = travellingCost.ToString("C0"),
                TypeID      = (int)NEstCostSummaryType.PriceA,
            };

            //-------------------------------------------------
            var t3A              = CostItems.Where(x => x.TypeID == (int)NEstCostType.InstallationLabour).ToList();
            var installHours     = t3A.Count == 0 ? 0 : t3A.Sum(x => x.Qty);
            var installHoursCost = MyConvert.ConvertToDouble(installHours * CostParameter.Configuration.LabourRateInstallation);


            //Material
            var t3B = CostItems.Where(x => x.TypeID == (int)NEstCostType.InstallationMaterail).ToList();
            var installationMaterialOriginalCost = t3B.Count == 0 ? 0 : t3B.Sum(x => x.SubTotal);

            installationMaterialOriginalCost = installationMaterialOriginalCost *
                                               CostParameter.Configuration.MarkupInstallationMaterial;
            installationMaterialOriginalCost = installationMaterialOriginalCost * CostParameter.Configuration.MaterialWastageRate;

            var t3c = CostItems.Where(x => x.TypeID == (int)NEstCostType.InstallationOther).ToList();
            var installationOtherCost = t3c.Count == 0 ? 0 : t3c.Sum(x => x.SubTotal);


            var t3D = CostItems.Where(x => x.TypeID == (int)NEstCostType.InstallationEquipment).ToList();
            var installationEquipmentCost = t3D.Count == 0 ? 0 : t3D.Sum(x => x.SubTotal);

            var installationCost = installHoursCost + (installationMaterialOriginalCost + installationOtherCost) * CostParameter.Configuration.MaterialMarkupPercentage *
                                   (1 + CostParameter.Configuration.DiscountRate) + installationEquipmentCost;

            var summary13Name = "Installation Cost" + "($" + Convert.ToString(CostParameter.Configuration.LabourRateInstallation) + ")";

            if (Math.Abs(modifyRate - 0) > 0.001)
            {
                summary13Name += modifyRateString;
            }

            var summary13 = new CR_Cost_Summary
            {
                Name            = summary13Name,
                ProjectID       = CostParameter.ProjectID,
                EstRevID        = CostParameter.EstRevID,
                EstItemID       = CostParameter.EstItemID,
                WorkorderID     = CostParameter.WorkorderID,
                WorkorderItemID = CostParameter.WorkorderItemID,

                OrderNumber = 13,
                Column0     = "",
                Column1     = "",
                Column2     = (installationCost).ToString("C0"),
                TypeID      = (int)NEstCostSummaryType.PriceA,
            };

            //-------------------------------------------------
            var targetPrice = supplyOnlyCost + travellingCost + installationCost;
            var summary14   = new CR_Cost_Summary
            {
                Name = "Target Price A",

                ProjectID       = CostParameter.ProjectID,
                EstRevID        = CostParameter.EstRevID,
                EstItemID       = CostParameter.EstItemID,
                WorkorderID     = CostParameter.WorkorderID,
                WorkorderItemID = CostParameter.WorkorderItemID,

                OrderNumber = 14,
                Column0     = "",
                Column1     = "",
                Column2     = (targetPrice).ToString("C0"),
                TypeID      = (int)NEstCostSummaryType.PriceA,
            };

            Values = new List <CR_Cost_Summary>()
            {
                summary01, summary02, summary11, summary12, summary13, summary14
            };

            //To Update DbTable
            TotalPrice = targetPrice;
        }
示例#10
0
        //Crating
        //Shipping
        //Local Installer
        public void Refresh()
        {
            if (CostItems == null)
            {
                return;
            }
            if (!CostItems.Any())
            {
                return;
            }

            var t01         = CostItems.Where(x => x.TypeID == (int)NEstCostType.CratingCost).ToList();
            var cratingCost = t01.Count == 0 ? 0 : t01.Sum(x => x.SubTotal);

            var t02          = CostItems.Where(x => x.TypeID == (int)NEstCostType.ShippingCost).ToList();
            var shippingCost = t02.Count == 0 ? 0 : t02.Sum(x => x.SubTotal);

            var t03 = CostItems.Where(x => x.CategoryID == (int)NEstCostTypeCategory.LocalInstallerCost).ToList();
            var localInstallerCost = t03.Count == 0 ? 0 : t03.Sum(x => x.SubTotal);


            var summary01 = new CR_Cost_Summary
            {
                Name = "Crating Cost(C.)",

                ProjectID       = CostParameter.ProjectID,
                EstRevID        = CostParameter.EstRevID,
                EstItemID       = CostParameter.EstItemID,
                WorkorderID     = CostParameter.WorkorderID,
                WorkorderItemID = CostParameter.WorkorderItemID,

                OrderNumber = 1,
                Column0     = "",
                Column1     = (Math.Round(cratingCost, 0)).ToString("C0"),
                Column2     = "",
                TypeID      = (int)NEstCostSummaryType.PriceExtra,
            };

            var summary02 = new CR_Cost_Summary
            {
                Name = "Shipping Cost(S.)",

                ProjectID       = CostParameter.ProjectID,
                EstRevID        = CostParameter.EstRevID,
                EstItemID       = CostParameter.EstItemID,
                WorkorderID     = CostParameter.WorkorderID,
                WorkorderItemID = CostParameter.WorkorderItemID,

                OrderNumber = 2,
                Column0     = "",
                Column1     = (Math.Round(shippingCost, 0)).ToString("C0"),
                Column2     = "",
                TypeID      = (int)NEstCostSummaryType.PriceExtra,
            };


            var summary03 = new CR_Cost_Summary
            {
                Name = "Local Installer Cost(L.)",

                ProjectID       = CostParameter.ProjectID,
                EstRevID        = CostParameter.EstRevID,
                EstItemID       = CostParameter.EstItemID,
                WorkorderID     = CostParameter.WorkorderID,
                WorkorderItemID = CostParameter.WorkorderItemID,

                OrderNumber = 3,
                Column0     = "",
                Column1     = (Math.Round(localInstallerCost, 0)).ToString("C0"),
                Column2     = "",
                TypeID      = (int)NEstCostSummaryType.PriceExtra,
            };

            TotalPrice = MyConvert.ConvertToDouble(cratingCost + shippingCost + localInstallerCost);
            var summary04 = new CR_Cost_Summary
            {
                Name = "C.S.L.",

                ProjectID       = CostParameter.ProjectID,
                EstRevID        = CostParameter.EstRevID,
                EstItemID       = CostParameter.EstItemID,
                WorkorderID     = CostParameter.WorkorderID,
                WorkorderItemID = CostParameter.WorkorderItemID,

                OrderNumber = 4,
                Column0     = "",
                Column1     = (Math.Round(TotalPrice, 0)).ToString("C0"),
                Column2     = "",
                TypeID      = (int)NEstCostSummaryType.PriceExtra,
            };

            Values = new List <CR_Cost_Summary>()
            {
                summary01, summary02, summary03, summary04
            };
        }
        public override string IsValidated()
        {
            var    b = true;
            string validationResult = "";

            //Number of Sign
            if (MyConvert.ConvertToDouble(Value.NumberOfSigns) == 0)
            {
                validationResult += "Number of Signs required." + System.Environment.NewLine;
                b = false;
            }

            //Estimated Value
            if (MyConvert.ConvertToDouble(Value.ProjectValueEstimated) == 0)
            {
                validationResult += "Estimated Project Valued  required." + System.Environment.NewLine;
                b = false;
            }

            //Installation Address
            var msc = new MySalesJobMasterListCustomer(BaseValue.JobID);

            msc.SetInstallTo();

            if (msc.CustomerID == 0)
            {
                validationResult += "No Installation Company Selected  " + System.Environment.NewLine;
                b = false;
            }
            else
            {
                var mc = new MyCustomer(msc.CustomerID);
                if (MyConvert.ConvertToString(mc.Value.ADDR_1).Length < 5)
                {
                    validationResult += "No Installation Address  " + System.Environment.NewLine;
                    b = false;
                }
            }


            //Landlord
            if (Value.LandlordID < 1000)
            {
                validationResult += "Enter a Landlord Please  " + System.Environment.NewLine;
                b = false;
            }
            else
            {
                var landlord = _db.PermitLandlords.Find(Value.LandlordID);
                //Company Name
                if (MyConvert.ConvertToString(landlord.NAME).Length < 5)
                {
                    validationResult += "Landlord Name Required" + System.Environment.NewLine;
                    b = false;
                }
                //Address
                if (MyConvert.ConvertToString(landlord.ADDR_1).Length < 5)
                {
                    validationResult += "Landlord Address Required " + System.Environment.NewLine;
                    b = false;
                }

                if (MyConvert.ConvertToString(landlord.CITY).Length < 3)
                {
                    validationResult += "Landlord City Required " + System.Environment.NewLine;
                    b = false;
                }

                if (MyConvert.ConvertToString(landlord.ZIPCODE).Length < 4)
                {
                    validationResult += "Landlord Postcode Required " + System.Environment.NewLine;
                    b = false;
                }
            }

            //Landlord Contact
            if (Value.LandlordContactID < 1000)
            {
                validationResult += "Enter a Landlord Contact  " + System.Environment.NewLine;
                b = false;
            }
            else
            {
                var contact = _db.PermitLandlordContacts.Find(Value.LandlordContactID);
                var l1      = MyConvert.ConvertToString(contact.CONTACT_FIRST_NAME).Length;
                var l2      = MyConvert.ConvertToString(contact.CONTACT_LAST_NAME).Length;
                if (l1 + l2 < 2)
                {
                    validationResult += "Landlord Contact Name Required" + System.Environment.NewLine;
                    b = false;
                }
                if (MyConvert.ConvertToString(contact.CONTACT_PHONE).Length < 9)
                {
                    validationResult += "Landlord Contact Phone Required" + System.Environment.NewLine;
                    b = false;
                }
            }

            //Document Attached
            var requiredDocuemntTypes = new int[] { 10, 12, 14, 16 };

            for (int i = 0; i < requiredDocuemntTypes.Length; i++)
            {
                var docTypeID   = requiredDocuemntTypes[i];
                var docAttached = _db.PermitDocuments.Where(x => x.BaseAppID == BaseValue.BaseAppID & x.DocType == docTypeID).ToList();
                if (!docAttached.Any( ))
                {
                    var docType = _db.PermitDocumentTypes.Find(docTypeID);
                    validationResult += "Document Required: " + docType.TypeName + System.Environment.NewLine;
                    b = false;
                }
            }

            return(b ? "ok" : validationResult);
        }
示例#12
0
        public void Generate()
        {
            var connectionSQL = new SqlConnection(SalesCenterConfiguration.ConnectionString);

            const string sqlSelectString2 = "SELECT *  FROM [Quote_Item] WHERE ([quoteItemID] = 0) ";
            var          selectCommand2   = new SqlCommand(sqlSelectString2, connectionSQL);
            var          adapter2         = new SqlDataAdapter(selectCommand2);

            var ds2 = new DataSet();

            ds2.Tables.Clear();

            try
            {
                connectionSQL.Open();
                adapter2.Fill(ds2, "t2");

                DataRow rowNew = ds2.Tables["t2"].NewRow();

                rowNew["quoteRevID"]   = _quoteRevID;
                rowNew["estItemID"]    = _row["estItemID"];
                rowNew["qiPrintOrder"] = _row["estItemNo"];
                rowNew["quoteOption"]  = _row["ItemOption"];
                rowNew["isFinal"]      = _row["isFinalOption"];

                int fwJobTypeRequirementID = Convert.ToInt32(_row["RequirementID"]);
                var sp = new SupplyType(fwJobTypeRequirementID);
                rowNew["supplyType"] = sp.QuoteSupplyTypeID;

                rowNew["qiItemTitle"] = _row["ProductName"];

                double qiAmount = MyConvert.ConvertToDouble(_row["PriceA"]);
                rowNew["qiAmount"] = qiAmount;

                rowNew["qiUnitPrice"] = 0;

                rowNew["qiDescription"] = "";

                rowNew["qiQty"]   = _row["Qty"];
                rowNew["qiQtyPC"] = 0;

                rowNew["Requirement"] = _row["RequirementID"];
                rowNew["Position"]    = "Indoor";

                rowNew["recordType"]      = "Q";
                rowNew["quoteOptionText"] = _row["ItemOption"];
                rowNew["qiAmountText"]    = qiAmount.ToString("F2");
                rowNew["nameDetailsID"]   = _row["ProductID"];
                rowNew["BySubcontractor"] = _row["BySubcontractor"];
                ds2.Tables["t2"].Rows.Add(rowNew);

                //4. Write ds2,  back to DB

                var cb = new SqlCommandBuilder(adapter2);
                adapter2 = cb.DataAdapter;

                adapter2.Update(ds2, "t2");

                NewlyInsertedQuoteItemID = SqlCommon.GetNewlyInsertedRecordID("Quote_Item");
            }
            catch (SqlException ex)
            {
                string errorLog = ex.Message;
            }
            finally
            {
                connectionSQL.Close();
            }
        }