Example #1
0
        public bool GetNewPart(MCSS model, Models.SessionInfo epiSession, out bool IsSucces, out string msgError)
        {
            try
            {
                Session currSession = new Session(epiSession.UserID, epiSession.UserPassword, epiSession.AppServer, Session.LicenseType.Default);
                Part myPart = new Part(currSession.ConnectionPool);

                bool partExst = false;
                string whereClausePart = string.Format(@"Part.PartNum='{0}'", model.McssNum);
                //whereClausePart.Replace("=\"","");
                PartDataSet dsPart = new PartDataSet();
                if (myPart.PartExists(model.McssNum))
                {
                    dsPart = myPart.GetRows(whereClausePart, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 0, 1, out partExst);
                }
                else
                {
                    myPart.GetNewPart(dsPart);
                }
               
                DataRow drPart = dsPart.Tables[0].Rows[0];
                drPart.BeginEdit();
                drPart["PartNum"] = model.McssNum;
                drPart["PartDescription"] = model.McssNum;
                drPart["UOMClassID"] = "UCC";
                drPart["TypeCode"] = "P";
                drPart["IUM"] = (model.Length > 0) ? "PCS" : "KG";  //Our UOM
                drPart["PUM"] = (model.Length > 0) ? "PCS" : "KG"; ;   //Purchasing UOM
                drPart["TypeCode"] = "M";
                drPart["SalesUM"] = (model.Length > 0) ? "PCS" : "KG"; ;   //Sale UOM
                drPart["Character02"] = "";  //NCR No.
                drPart["Character08"] = string.IsNullOrEmpty(model.CustID) ? "" : model.CustID;
                drPart["Character10"] = ""; //Pack No.
                drPart["ShortChar01"] = string.IsNullOrEmpty(model.CommodityCode) ? "" : model.CommodityCode;
                drPart["ShortChar02"] = string.IsNullOrEmpty(model.MatSpec1) ? "" : model.MatSpec1;
                drPart["ShortChar07"] = "";  //Old Stock No.
                drPart["ShortChar09"] = string.IsNullOrEmpty(model.Coating1) ? "" : model.Coating1;
                drPart["ShortChar10"] = "6";  //PartStatus = MCSS
                drPart["Number01"] = model.Thick;
                drPart["Number02"] = model.Width;
                drPart["Number03"] = model.Length;
                drPart["TrackLots"] = 1;
                drPart["Number11"] = 1;
                drPart["Number12"] = model.Pocession.GetInt();
                drPart["Character10"] = "N";

                drPart["NetWeight"] = model.WeightPerCoilMin.GetDecimal();
                drPart.EndEdit();

                myPart.Update(dsPart);

                currSession.Dispose();

                IsSucces = true;
                msgError = "";
            }
            catch (Exception ex)
            {
                IsSucces = false;
                msgError = ex.Message;
            }
            return IsSucces;
        }