Example #1
0
        internal static int saveCFSRecord(BID04_MaterialDetail material)
        {
            int result = 0;

            try
            {
                string spName = string.Empty;
                List <SqlParameter> parametersList = new List <SqlParameter>();
                spName = "spATL_LBID_MatDtl_Ins";

                parametersList.Add(new SqlParameter("@BIDMatHeaderID", material.BIDMatHeaderID));
                parametersList.Add(new SqlParameter("@PartNum", material.PartNum));
                parametersList.Add(new SqlParameter("@PartNumDesc", material.PartNumDesc));
                parametersList.Add(new SqlParameter("@Qty", material.Qty));
                parametersList.Add(new SqlParameter("@UOM", material.UOM));
                parametersList.Add(new SqlParameter("@Cost", material.Cost));
                parametersList.Add(new SqlParameter("@ImportFlag", material.ImportFlag));


                DataTable resultSet = (SqlHelper.ExecuteDataset(_myConnection, CommandType.StoredProcedure,
                                                                spName, parametersList.ToArray()).Tables[0]);

                result = Convert.ToInt32(resultSet.Rows[0][0]);
            }
            catch (Exception ex)
            {
                Logger.SaveErr(ex);
                result = -1;
            }
            return(result);
        }
Example #2
0
 private static int saveSingleCFS(BID04_MaterialDetail materialDtl)
 {
     //Links to the corrisponding header record.
     saveCFSRecord(materialDtl);
     materialDtl = new BID04_MaterialDetail();
     //This update updates a single line item record.
     return(0);
 }
Example #3
0
        public static List <BID04_MaterialDetail> GetBidMaterialDetails(int id)
        {
            List <BID04_MaterialDetail> materialDtl = new List <BID04_MaterialDetail>();
            var materials = SqlHelper.ExecuteDataset(_myConnection, CommandType.StoredProcedure, "spATL_LBID_ViewMakeItems",
                                                     new SqlParameter("@matheaderid", id)).Tables[0].AsEnumerable();

            foreach (var item in materials)
            {
                BID04_MaterialDetail material = new BID04_MaterialDetail();
                material.BIDMatDtlID    = Convert.ToInt32(item["BIDMatDtlID"]);
                material.BIDMatDtlID    = Convert.ToInt32(item["BIDMatDtlID"]);
                material.BIDMatHeaderID = Convert.ToInt32(item["BIDMatDtlID"]);
                material.PartNum        = Convert.ToString(item["PartNum"]);
                material.PartNumDesc    = Convert.ToString(item["PartNumDesc"]);
                material.Qty            = Convert.ToDecimal(item["Qty"]);
                material.UOM            = Convert.ToString(item["UOM"]);
                material.Cost           = Convert.ToDecimal(item["Cost"]);
                materialDtl.Add(material);
            }

            return(materialDtl);
        }
Example #4
0
        public static int saveCFSFile(HttpPostedFileBase file, int materialID, bool isCostOveridden, string bidid, string cfsDataPath = "")
        {
            int result = 0;

            try
            {
                System.IO.StreamReader iStream  = new System.IO.StreamReader(file.InputStream);
                List <string>          strLines = new List <string>();
                while (!iStream.EndOfStream)
                {
                    // reading 1 line of datafile
                    strLines.Add(iStream.ReadLine());
                }
                int i = 0, x = 1, n = 0, g = 0, fab_count = 0, line = 0;

                byte   fab_exist, IsFab = 0;
                string version = strLines[0];
                BID04_MaterialDetail materialDtl = new BID04_MaterialDetail();

                DataSet ds = new DataSet();
                ds.ReadXml(cfsDataPath);
                DataTable tblLine = ds.Tables[0];
                DataTable tblUOM  = ds.Tables[1];


                if (isCostOveridden)
                {
                    string query = "UPDATE [dbo].[BID03_MaterialHeader] SET [OverRiddenCost] ='" + strLines[3] + "'  WHERE [BIDMatHeaderID] =" + materialID;
                    SqlHelper.ExecuteNonQuery(_myConnection, CommandType.Text, query);
                }

                #region CFS File
                for (int counter = 0; counter <= strLines.Count; counter++)
                {
                    //We're skipping lines we don't care about... there's a lot of them.
                    if (counter < GetLineNum(tblLine, "FIRST_REAL_LINE"))
                    {
                    }
                    else
                    {
                        if (x == GetLineNum(tblLine, "INV_QTY_LINE"))
                        {
                            var InvoiceQuantity = strLines[counter - 1];
                        }
                        if (x == GetLineNum(tblLine, "CALC_FT_PIPE_LINE"))
                        {
                            var CalcFtPipeLine = strLines[counter - 1];
                        }
                        if (x == GetLineNum(tblLine, "CFS_RECORD_LINE"))
                        {
                            var s = strLines[counter - 1];
                        }
                        if (x == GetLineNum(tblLine, "QTY_LINE"))
                        {
                            var qty = strLines[counter - 1];
                            if (string.IsNullOrWhiteSpace(qty) || Int32.Parse(qty).Equals(0))
                            {
                                break;
                            }
                            materialDtl.Qty = Convert.ToDecimal(qty);
                        }

                        if (x == GetLineNum(tblLine, "ITEM_NUM_LINE"))
                        {
                            var itm = Convert.ToString(FormatLine(strLines[counter - 1]));
                            if (itm == "FABRICATED")
                            {
                                materialDtl.ImportFlag = 1;
                                //Throw up a flag for fabricated items.
                                fab_exist = 1;
                                //Don't forget to convert them to gate parts.
                                fab_count = fab_count + 1;
                                IsFab     = 1;
                            }
                            if (itm == "NONE")
                            {
                                //Flag for "NONE" in the item number field.
                                materialDtl.ImportFlag = 1;
                            }
                            if ((itm == "CONCPOUR" || itm == "CONCHAND"))
                            {
                                //Flag for "CONCRETE" in the item number field.
                                materialDtl.ImportFlag = 1;
                            }
                            if ((itm == "CLRATE17LBR"))
                            {
                                //Flag for "CLRATE17LBR" in the item number field.
                                materialDtl.ImportFlag = 1;
                            }
                            //oRs("PartNum") = StripChars(itm, "AMS-");
                            materialDtl.PartNum = itm.Replace("AMS-", "");
                        }
                        if (x == GetLineNum(tblLine, "DESCR_LINE"))
                        {
                            string des      = Convert.ToString(strLines[counter - 1]);
                            bool   bDblGate = false;
                            if (!string.IsNullOrWhiteSpace(des) && des.ToUpper().Substring(0, 6).Equals("SPECIAL"))
                            {
                                //Flag for "SPECIAL" in the begining of description line.
                                materialDtl.ImportFlag = 1;
                            }

                            if (Convert.ToBoolean(IsFab))
                            {
                                string partnum = BuildGatePartNumber(des, out bDblGate);
                                if (partnum.Length != 0)
                                {
                                    materialDtl.PartNum    = partnum;
                                    materialDtl.ImportFlag = 0;
                                }
                                IsFab = 0;
                            }

                            if (materialDtl.PartNum.StartsWith("P"))
                            {
                                materialDtl.PartNum = ConvertPNumber(materialDtl.PartNum);
                            }

                            if (bDblGate)
                            {
                                string desc = GetDescription(materialDtl.PartNum) + " **USE AS DOUBLE DRIVE** ";
                                materialDtl.PartNum = Convert.ToString(Int32.Parse(materialDtl.PartNum) * 2);
                                bDblGate            = false;
                            }

                            // oRs("ProdLineID") = GetProdLine(oRs("PartNum"));
                            // oRs("ProcurementTypeId") = GetProcureType(oRs("PartNum"));
                            materialDtl.PartNumDesc = des;
                        }
                        //Simple unit of measure notation oConveoRsions.
                        if (x == GetLineNum(tblLine, "UOM_LINE"))
                        {
                            string uom = Convert.ToString(strLines[counter - 1]);
                            materialDtl.UOM = GetUOMDesc(tblUOM, uom);
                        }
                        if (x == GetLineNum(tblLine, "SELL_PRICE_LINE"))
                        {
                            // sellprice = Strings.Trim(iStream.ReadLine);
                            //oRs("sellprice") = sellprice
                        }
                        if (x == GetLineNum(tblLine, "HANDLING_LINE"))
                        {
                            // handling = Strings.Trim(iStream.ReadLine);
                            //oRs("handling") = handling
                            var cost = Convert.ToDecimal(strLines[counter - 1]);
                            materialDtl.Cost = Convert.ToDecimal(cost);
                        }
                        if (x == GetLineNum(tblLine, "STD_WT_LINE"))
                        {
                            // std_wt = Strings.Trim(iStream.ReadLine);
                            //oRs("std_wt") = std_wt
                        }
                        if (x == GetLineNum(tblLine, "IN_YARD_COST_LINE"))
                        {
                            //   yardcost = Strings.Trim(iStream.ReadLine);
                            //oRs("yardcost") = yardcost
                        }
                        if (x == GetLineNum(tblLine, "DISCOUNT_FACTOR_LINE"))
                        {
                            //   discount = Strings.Trim(iStream.ReadLine);
                            //oRs("discount") = discount
                        }

                        if ((version == "8.0W"))
                        {
                            if (x == GetLineNum(tblLine, "EXTRA_LINE14"))
                            {
                            }
                            if (x == GetLineNum(tblLine, "EXTRA_LINE15"))
                            {
                                x = 0;
                            }
                        }
                        else if ((version == "9.0W"))
                        {
                            if (x == GetLineNum(tblLine, "EXTRA_LINE14"))
                            {
                            }

                            if (x == GetLineNum(tblLine, "EXTRA_LINE15"))
                            {
                            }

                            if (x == GetLineNum(tblLine, "EXTRA_LINE16"))
                            {
                            }

                            if (x == GetLineNum(tblLine, "EXTRA_LINE17"))
                            {
                                materialDtl.BIDMatHeaderID = materialID;
                                x = saveSingleCFS(materialDtl);
                                x = 0;
                            }
                        }
                        else if ((version == "10.1W"))
                        {
                            if (x == GetLineNum(tblLine, "EXTRA_LINE14"))
                            {
                            }

                            if (x == GetLineNum(tblLine, "EXTRA_LINE15"))
                            {
                            }

                            if (x == GetLineNum(tblLine, "EXTRA_LINE16"))
                            {
                            }

                            if (x == GetLineNum(tblLine, "EXTRA_LINE17"))
                            {
                                materialDtl.BIDMatHeaderID = materialID;
                                x = saveSingleCFS(materialDtl);
                            }

                            if (x == GetLineNum(tblLine, "EXTRA_LINE18"))
                            {
                                //materialDtl.BIDMatHeaderID = materialID;
                                //x = saveSingleCFS(materialDtl);
                            }
                        }
                        else if (x == GetLineNum(tblLine, "EXTRA_LINE14"))
                        {
                            materialDtl.BIDMatHeaderID = materialID;
                            x           = saveSingleCFS(materialDtl);
                            x           = 0;
                            materialDtl = new BID04_MaterialDetail();
                            //  iStream.SkipLine
                        }

                        x = x + 1;
                    }
                }
                #endregion

                result = 1;
            }
            catch (Exception ex)
            {
                Logger.SaveErr(ex);
                DeleteExistingCFS(Convert.ToInt32(bidid), 1);
                result = -1;
            }
            return(result);
        }