public int delMachineTypeByNames(string machineName)
        {
            string sql     = @"DELETE FROM machineTypes WHERE machineName ='" + machineName + "'";
            int    delRows = IEBOM_SqlHelper.ExecuteNonQuery(sql);

            return(delRows);
        }
        public int saveLearningCurveName(string CurveName)
        {
            string sql = @"
                            INSERT INTO	dbo.CureNames
                            (
                               
                                modulusName,
                                isNewStyle,
                                isDel,
                                Remark
                            )
                            VALUES
                            (  
                                 @CurveName, 
                                0, 
                                0, 
                                N''
                                )  SELECT IDENT_CURRENT('CureNames')";

            SqlParameter[] ps =
            {
                new SqlParameter("CurveName", CurveName)
            };
            return(IEBOM_SqlHelper.ExcuteScalar <int>(sql, ps));
        }
 public void cModulusNames(DataRow dr, StyleLearingCurve list)
 {
     list.id          = Convert.ToInt32(IEBOM_SqlHelper.FromDbValue(dr["id"]));
     list.modulusName = Convert.ToString(IEBOM_SqlHelper.FromDbValue(dr["modulusName"]));
     list.isNewStyle  = Convert.ToBoolean(IEBOM_SqlHelper.FromDbValue(dr["isNewStyle"]));
     list.remark      = Convert.ToString(IEBOM_SqlHelper.FromDbValue(dr["Remark"]));
 }
 public void dataToMachines(DataRow dr, MODEL.Machines list)
 {
     list.machineClass     = Convert.ToString(IEBOM_SqlHelper.FromDbValue(dr["machineClass"]));    // 机器类别
     list.machineName      = Convert.ToString(IEBOM_SqlHelper.FromDbValue(dr["MachineName"]));     // 机器类别名称
     list.machineNameEN    = Convert.ToString(IEBOM_SqlHelper.FromDbValue(dr["machineNameEN"]));   // 机器类别名称英文
     list.MachinesMark     = Convert.ToString(IEBOM_SqlHelper.FromDbValue(dr["machinesMark"]));    // 机器备注
     list.isMachinesStatus = Convert.ToInt32(IEBOM_SqlHelper.FromDbValue(dr["isMachinesStatus"])); // 机器类别状态
     list.CreateDate       = Convert.ToDateTime(IEBOM_SqlHelper.FromDbValue(dr["CreateDate"]));    // 创建时间
     list.Creator          = Convert.ToString(IEBOM_SqlHelper.FromDbValue(dr["Creator"]));         // 创建者
     list.modify           = Convert.ToDateTime(IEBOM_SqlHelper.FromDbValue(dr["modify"]));        // 最后修改时间
     list.modifor          = Convert.ToString(IEBOM_SqlHelper.FromDbValue(dr["modifor"]));         //  最后修改者
 }
        public int delStandardModulusByCurveNameID(int CurveNameID)
        {
            string sql = @"UPDATE dbo.StandardModulus SET isDel = 1 WHERE CureNamesID =@CurveNameID";


            SqlParameter[] ps =
            {
                new SqlParameter("CurveNameID", CurveNameID)
            };
            int result = IEBOM_SqlHelper.ExecuteNonQuery(sql, ps);

            return(result);
        }
        public int getLearningByCurveName(string CurveName)
        {
            string sql     = @"SELECT id FROM CureNames WHERE modulusName =@CurveName";
            int    namesid = -1;

            SqlParameter[] ps =
            {
                new SqlParameter("CurveName", CurveName)
            };
            DataTable dt = IEBOM_SqlHelper.ExcuteTable(sql, ps);

            if (dt.Rows.Count > 0)
            {
                namesid = Convert.ToInt32(dt.Rows[0][0].ToString());
            }
            return(namesid);
        }
        public List <string> getIEVersions(string styleNumber)
        {
            List <string> versions = new List <string>();
            string        sql      = @"SELECT IEBomVersion  FROM dbo.IEBomBase	 WHERE IEBomStyleName=@styleNumber";

            SqlParameter[] paras =
            {
                new SqlParameter("@styleNumber", styleNumber)
            };

            DataTable dt = IEBOM_SqlHelper.ExcuteTable(sql, paras);

            if (dt != null && dt.Rows.Count > 0)
            {
            }
            List <string> IEVersions

            return
        }
        public DataTable getStandardModulusByCurveNameID(int CurveNameID)
        {
            string sql = @"SELECT 
                                   CureNamesID,
                                   CArea,
                                   Clevel,
                                   CsingleMinute,
                                   Cratio,
                                   COneday,
                                   CTwoDay,
                                   CThreeDay,
                                   CFourDay,
                                   CFiveDay,
                                   CSixDay,
                                   CSevenDay,
                                   CEightDay,
                                   CNineDay,
                                   CTenDay,
                                   CElevenDay,
                                   CTwelveDay,
                                   CThirteenDay,
                                   CFourteenDay,
                                   Creator,
                                   CreateDate,
                                   modiyDate,
                                   modiyed,
                                   isNewStyle,
                                   isDel
                            FROM dbo.StandardModulus
                            WHERE CureNamesID = @CurveNameID
                                  AND isdel IS NULL;";


            SqlParameter[] ps =
            {
                new SqlParameter("CurveNameID", CurveNameID)
            };
            DataTable dt = IEBOM_SqlHelper.ExcuteTable(sql, ps);

            return(dt);
        }
        public DataTable getAllMachineTypes()
        {
            string sql = @"SELECT  
                                   machineClass,
                                   MachineName,
                                   machineNameEN,
                                   machinesMark,
                                   CreateDate,
                                   Creator,
                                   modify,
                                   modifor,
                                   ismachinesStatus
                            FROM machinetypes
                            ORDER BY ismachinesStatus,                                    
                                     machineClass; ";


            DataTable dt = IEBOM_SqlHelper.ExcuteTable(sql);

            return(dt);

            /*
             *
             * List<Machines> machinesLists = null;
             *
             * if (dt != null && dt.Rows.Count > 0)
             * {
             *  DataRow dr = dt.Rows[0];
             *  machinesLists = new List<Machines>();
             *  foreach (DataRow row in dt.Rows)
             *  {
             *      MODEL.Machines c = new MODEL.Machines();
             *      dataToMachines(row, c);
             *      machinesLists.Add(c);
             *  }
             * }
             *
             * return machinesLists;
             */
        }
        public List <StyleLearingCurve> getCurveNames()
        {
            string sql = @"SELECT id,
                                   modulusName,
                                   isNewStyle,
                                   Remark
                            FROM dbo.CureNames
                            WHERE isDel = 0;";

            List <StyleLearingCurve> lists = new List <StyleLearingCurve>();
            DataTable modulusNames         = IEBOM_SqlHelper.ExcuteTable(sql);

            if (modulusNames.Rows.Count > 0)
            {
                foreach (DataRow row in modulusNames.Rows)
                {
                    StyleLearingCurve c = new StyleLearingCurve();
                    cModulusNames(row, c);
                    lists.Add(c);
                }
            }
            return(lists);
        }
        public List <string> saveMachineTypes(DataTable machineDT)
        {
            List <string> results = new List <string>();

            DataTable newDt = new DataTable();

            //  newDt.Columns.Add(new DataColumn("machineID", typeof(int))); //
            newDt.Columns.Add(new DataColumn("machineClass", typeof(string)));  //机器类别
            newDt.Columns.Add(new DataColumn("MachineName", typeof(string)));   //机器类别名称
            newDt.Columns.Add(new DataColumn("machineNameEN", typeof(string))); //机器类别名称英文
            newDt.Columns.Add(new DataColumn("machinesMark", typeof(string)));  //机器备注
            newDt.Columns.Add(new DataColumn("isMachinesStatus", typeof(int))); //机器类别状态
            newDt.Columns.Add(new DataColumn("CreateDate", typeof(DateTime)));  // 创建时间
            newDt.Columns.Add(new DataColumn("Creator", typeof(string)));       // 创建者
            newDt.Columns.Add(new DataColumn("modify", typeof(DateTime)));      // 最后修改时间
            newDt.Columns.Add(new DataColumn("modifor", typeof(string)));       //  最后修改者


            for (int i = 0; i < machineDT.Rows.Count; i++)
            {
                DataRow dr = newDt.NewRow();
                dr["machineClass"]  = machineDT.Rows[i]["machineClass"];
                dr["MachineName"]   = machineDT.Rows[i]["MachineName"];
                dr["machineNameEN"] = machineDT.Rows[i]["machineNameEN"];
                dr["machinesMark"]  = machineDT.Rows[i]["machinesMark"];

                dr["isMachinesStatus"] = machineDT.Rows[i]["ismachinesStatus"];
                dr["CreateDate"]       = machineDT.Rows[i]["CreateDate"];
                dr["Creator"]          = machineDT.Rows[i]["Creator"];
                dr["modify"]           = machineDT.Rows[i]["modify"];
                dr["modifor"]          = machineDT.Rows[i]["modifor"];

                newDt.Rows.Add(dr);
            }

            // 清空临时表
            string empTmp = @"DELETE FROM machineTypes_tmp";

            IEBOM_SqlHelper.ExecuteNonQuery(empTmp);


            //写入临时表
            string result  = IEBOM_SqlHelper.SqlBulkCopyMachineTypes(newDt);
            int    newData = 0;


            // 写入成功 调用存储过程 失败返回原因
            if (result == "0")
            {
                string callStudent = @"exec get_NewMachines;";
                newData = IEBOM_SqlHelper.ExecuteNonQuery(callStudent);
                //  return newData.ToString();
                results.Add("0");
                results.Add(newData.ToString());
            }
            else
            {
                results.Add(result);
                results.Add("0");
            }

            return(results);
        }
        public string saveLearningCurve(DataTable newDt)
        {
            string result = IEBOM_SqlHelper.SqlBulkCopy(newDt);

            return(result);
        }