Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CtlDBAccess.Model.SysCfgDBModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SysCfg(");
            strSql.Append("sysCfgName,cfgFile,modifyTime,tag1,tag2)");
            strSql.Append(" values (");
            strSql.Append("@sysCfgName,@cfgFile,@modifyTime,@tag1,@tag2)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sysCfgName", SqlDbType.NVarChar,  50),
                new SqlParameter("@cfgFile",    SqlDbType.Text),
                new SqlParameter("@modifyTime", SqlDbType.DateTime),
                new SqlParameter("@tag1",       SqlDbType.NChar,     10),
                new SqlParameter("@tag2",       SqlDbType.NChar, 10)
            };
            parameters[0].Value = model.sysCfgName;
            parameters[1].Value = model.cfgFile;
            parameters[2].Value = model.modifyTime;
            parameters[3].Value = model.tag1;
            parameters[4].Value = model.tag2;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        private void OnSaveCfg()
        {
            CtlDBAccess.BLL.SysCfgBll sysCfgBll = new CtlDBAccess.BLL.SysCfgBll();

            if (!sysCfgBll.Exists(SysCfg.SysCfgModel.SysCfgFileName))
            {
                CtlDBAccess.Model.SysCfgDBModel cfgModel = new CtlDBAccess.Model.SysCfgDBModel();
                cfgModel.sysCfgName = SysCfg.SysCfgModel.SysCfgFileName;
                cfgModel.cfgFile    = this.richTextBox1.Text;
                cfgModel.modifyTime = System.DateTime.Now;
                sysCfgBll.Add(cfgModel);
            }
            else
            {
                CtlDBAccess.Model.SysCfgDBModel cfgModel = sysCfgBll.GetModel(SysCfg.SysCfgModel.SysCfgFileName);
                cfgModel.cfgFile    = this.richTextBox1.Text;
                cfgModel.modifyTime = System.DateTime.Now;
                sysCfgBll.Update(cfgModel);
            }
            string reStr = "";

            XElement root = null;

            SysCfg.SysCfgModel.LoadCfg(ref root, ref reStr);
            MessageBox.Show("配置文件已保存!");
        }
Example #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CtlDBAccess.Model.SysCfgDBModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SysCfg set ");
            strSql.Append("cfgFile=@cfgFile,");
            strSql.Append("modifyTime=@modifyTime,");
            strSql.Append("tag1=@tag1,");
            strSql.Append("tag2=@tag2");
            strSql.Append(" where sysCfgName=@sysCfgName ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@cfgFile",    SqlDbType.Text),
                new SqlParameter("@modifyTime", SqlDbType.DateTime),
                new SqlParameter("@tag1",       SqlDbType.NChar,     10),
                new SqlParameter("@tag2",       SqlDbType.NChar,     10),
                new SqlParameter("@sysCfgName", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.cfgFile;
            parameters[1].Value = model.modifyTime;
            parameters[2].Value = model.tag1;
            parameters[3].Value = model.tag2;
            parameters[4].Value = model.sysCfgName;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        private void OnSaveCfg()
        {
            CtlDBAccess.BLL.SysCfgBll sysCfgBll = new CtlDBAccess.BLL.SysCfgBll();

            if (!sysCfgBll.Exists(SysCfg.SysCfgModel.SysCfgFileName))
            {
                CtlDBAccess.Model.SysCfgDBModel cfgModel = new CtlDBAccess.Model.SysCfgDBModel();
                cfgModel.sysCfgName = SysCfg.SysCfgModel.SysCfgFileName;
                cfgModel.cfgFile    = this.richTextBox1.Text;
                cfgModel.modifyTime = System.DateTime.Now;
                sysCfgBll.Add(cfgModel);
            }
            else
            {
                CtlDBAccess.Model.SysCfgDBModel cfgModel = sysCfgBll.GetModel(SysCfg.SysCfgModel.SysCfgFileName);
                cfgModel.cfgFile    = this.richTextBox1.Text;
                cfgModel.modifyTime = System.DateTime.Now;
                sysCfgBll.Update(cfgModel);
            }
            string reStr = "";


            string xmlCfgFile = System.AppDomain.CurrentDomain.BaseDirectory + @"data/AcCfg.xml";

            SysCfg.SysCfgModel.LoadCfg(xmlCfgFile, ref reStr);
            MessageBox.Show("配置文件已保存!");
        }
Example #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CtlDBAccess.Model.SysCfgDBModel DataRowToModel(DataRow row)
 {
     CtlDBAccess.Model.SysCfgDBModel model = new CtlDBAccess.Model.SysCfgDBModel();
     if (row != null)
     {
         if (row["sysCfgName"] != null)
         {
             model.sysCfgName = row["sysCfgName"].ToString();
         }
         if (row["cfgFile"] != null)
         {
             model.cfgFile = row["cfgFile"].ToString();
         }
         if (row["modifyTime"] != null && row["modifyTime"].ToString() != "")
         {
             model.modifyTime = DateTime.Parse(row["modifyTime"].ToString());
         }
         if (row["tag1"] != null)
         {
             model.tag1 = row["tag1"].ToString();
         }
         if (row["tag2"] != null)
         {
             model.tag2 = row["tag2"].ToString();
         }
     }
     return(model);
 }
Example #6
0
        private void OnDispCfg()
        {
            this.richTextBox1.Text = "";

            CtlDBAccess.BLL.SysCfgBll       sysCfgBll = new CtlDBAccess.BLL.SysCfgBll();
            CtlDBAccess.Model.SysCfgDBModel cfgModel  = sysCfgBll.GetModel(SysCfg.SysCfgModel.SysCfgFileName);
            if (cfgModel != null)
            {
                this.richTextBox1.Text = cfgModel.cfgFile;
            }
        }
Example #7
0
        //   public static bool HouseEnabledA { get; set; }
        //   public static bool HouseEnabledB { get; set; }
        public static bool SaveCfg(ref string reStr)
        {
            try
            {
                CtlDBAccess.BLL.SysCfgBll       sysCfgBll = new CtlDBAccess.BLL.SysCfgBll();
                CtlDBAccess.Model.SysCfgDBModel cfgModel  = sysCfgBll.GetModel(SysCfg.SysCfgModel.SysCfgFileName);
                XElement root = rootXE;
                //  string xmlCfgFile = SysCfgModel.CfgFile;// System.AppDomain.CurrentDomain.BaseDirectory + @"data/NBssCfg.xml";
                //if (cfgModel == null)
                //{
                //    reStr = "系统配置不存在!";
                //    return false;
                //}
                //root = XElement.Parse(cfgModel.cfgFile);
                //if (root == null)
                //{
                //    reStr = "系统配置不存在!";
                //    return false;
                //}
                //  XElement runModeXE = root.Element("sysSet").Element("RunMode");
                //if(runModeXE.Attribute("UnBindedMode") != null)
                //{
                //    runModeXE.Attribute("UnBindedMode").Value =  SysCfg.SysCfgModel.UnbindMode.ToString();

                //}

                //XElement root = XElement.Load(xmlCfgFile);
                XElement asrsStoreCfgXE = root.Element("sysSet").Element("AsrsStoreCfg");
                asrsStoreCfgXE.Attribute("StoreTime").Value = AsrsStoreTime.ToString();
                //  XElement asrsBatchCfgXE = root.Element("sysSet").Element("AsrsBatchCfg");
                //asrsBatchCfgXE.Attribute("HouseACheckin").Value = CheckinBatchDic["A1库房"];
                //asrsBatchCfgXE.Attribute("HouseACheckout").Value = CheckoutBatchDic["A1库房"];
                //asrsBatchCfgXE.Attribute("HouseBCheckin").Value = CheckinBatchDic["B1库房"];
                //asrsBatchCfgXE.Attribute("HouseBCheckout").Value = CheckoutBatchDic["B1库房"];
                //asrsBatchCfgXE.Attribute("HouseC1Checkout").Value = CheckoutBatchDic["C1库房"];
                //asrsBatchCfgXE.Attribute("HouseC2Checkout").Value = CheckoutBatchDic["C2库房"];
                //  XElement asrsEnableXE = root.Element("sysSet").Element("AsrsEnableSet");
                // asrsEnableXE.Attribute("HouseEnabledA").Value = HouseEnabledA.ToString();
                //   asrsEnableXE.Attribute("HouseEnabledB").Value = HouseEnabledB.ToString();
                // root.Save(xmlCfgFile);
                if (cfgModel != null)
                {
                    cfgModel.cfgFile = root.ToString();
                    sysCfgBll.Update(cfgModel);
                }

                return(true);
            }
            catch (Exception ex)
            {
                reStr = ex.ToString();
                return(false);
            }
        }
Example #8
0
        private bool LoadAreaColorCfg(ref string reStr)
        {
            try
            {
                CtlDBAccess.BLL.SysCfgBll       sysCfgBll = new CtlDBAccess.BLL.SysCfgBll();
                CtlDBAccess.Model.SysCfgDBModel cfgModel  = sysCfgBll.GetModel(SysCfg.SysCfgModel.SysCfgFileName);
                XElement root = null;

                if (cfgModel == null)
                {
                    reStr = "系统配置不存在!";
                    return(false);
                }
                root = XElement.Parse(cfgModel.cfgFile);
                if (root == null)
                {
                    reStr = "系统配置不存在!";
                    return(false);
                }
                IEnumerable <XElement> houseArea = root.Element("sysSet").Element("HouseAreaColorSet").Elements("HouseArea");

                if (houseArea == null)
                {
                    reStr = "系统逻辑库存颜色信息不存在!";
                    return(false);
                }

                foreach (XElement element in houseArea)
                {
                    string   houseAreaID = element.Attribute("houseAreaID").Value;
                    string   areaName    = element.Attribute("areaName").Value;
                    string[] rgbArr      = element.Value.Split(',');
                    //if (this.areaColor.Keys.Contains(long.Parse(houseAreaID))==true)
                    //{
                    //    continue;
                    //}
                    this.areaColor[long.Parse(houseAreaID)] = Color.FromArgb(int.Parse(rgbArr[0]), int.Parse(rgbArr[1]), int.Parse(rgbArr[2]));
                }
                ShowAreaColor();

                return(true);
            }
            catch (Exception ex)
            {
                reStr = ex.ToString();
                return(false);
            }
        }
Example #9
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CtlDBAccess.Model.SysCfgDBModel GetModel(string sysCfgName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 sysCfgName,cfgFile,modifyTime,tag1,tag2 from SysCfg ");
            strSql.Append(" where sysCfgName=@sysCfgName ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sysCfgName", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = sysCfgName;

            CtlDBAccess.Model.SysCfgDBModel model = new CtlDBAccess.Model.SysCfgDBModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #10
0
        public static bool LoadCfgDB(ref XElement root, ref string reStr)
        {
            try
            {
                CheckinBatchDic  = new Dictionary <string, string>();
                CheckoutBatchDic = new Dictionary <string, string>();
                stepSeqs.Clear();
                //投产绑定,一次高温,OCV1,二次绑定,二次高温,冷却,OCV2,OCV3,常温老化,OCV4,下线入库
                stepSeqs.AddRange(new string[] { "PS-1", "PS-2", "PS-3", "PS-4", "PS-5", "PS-6", "PS-7", "PS-8", "PS-9", "PS-10", "PS-11" });

                CtlDBAccess.BLL.SysCfgBll       sysCfgBll = new CtlDBAccess.BLL.SysCfgBll();
                CtlDBAccess.Model.SysCfgDBModel cfgModel  = sysCfgBll.GetModel(SysCfg.SysCfgModel.SysCfgFileName);

                //SysCfgModel.CfgFile = cfgFile;


                if (cfgModel == null)
                {
                    reStr = "系统配置不存在";
                    return(false);
                }
                root = XElement.Parse(cfgModel.cfgFile);
                if (root == null)
                {
                    reStr = "系统配置不存在!";
                    return(false);
                }


                XElement asrsStoreCfgXE = root.Element("sysSet").Element("AsrsStoreCfg");
                AsrsStoreTime = float.Parse(asrsStoreCfgXE.Attribute("StoreTime").Value);

                XElement runModeXE = root.Element("sysSet").Element("RunMode");
                string   simStr    = runModeXE.Attribute("sim").Value.ToString().ToUpper();
                if (simStr == "TRUE")
                {
                    SimMode = true;
                }
                else
                {
                    SimMode = false;
                }
                if (runModeXE.Attribute("RfidSimMode") != null)
                {
                    string strRfidSim = runModeXE.Attribute("RfidSimMode").Value.ToString().ToUpper();
                    if (strRfidSim == "TRUE")
                    {
                        RfidSimMode = true;
                    }
                    else
                    {
                        RfidSimMode = false;
                    }
                }
                if (runModeXE.Attribute("UnBindedMode") != null)
                {
                    string unbindedStr = runModeXE.Attribute("UnBindedMode").Value.ToString().ToUpper();
                    if (unbindedStr == "TRUE")
                    {
                        UnbindMode = true;
                    }
                    else
                    {
                        UnbindMode = false;
                    }
                }
                //if(root.Element("sysSet").Element("AsrsBatchSet") != null &&
                //    root.Element("sysSet").Element("AsrsBatchSet").Element("CheckInBatch") != null)
                //{

                //}
                XElement asrsBatchCfgXE = root.Element("sysSet").Element("AsrsBatchCfg");
                CheckinBatchDic["A1库房"] = asrsBatchCfgXE.Attribute("HouseACheckin").Value.ToString();
                CheckinBatchDic["B1库房"] = asrsBatchCfgXE.Attribute("HouseBCheckin").Value.ToString();
                //CheckinBatchDic["C1库房"] = asrsBatchCfgXE.Attribute("HouseC1Checkin").Value.ToString();
                //CheckinBatchDic["C2库房"] = asrsBatchCfgXE.Attribute("HouseC2Checkin").Value.ToString(); ;

                CheckoutBatchDic["A1库房"] = asrsBatchCfgXE.Attribute("HouseACheckout").Value.ToString();
                CheckoutBatchDic["B1库房"] = asrsBatchCfgXE.Attribute("HouseBCheckout").Value.ToString();
                //CheckoutBatchDic["C1库房"] = asrsBatchCfgXE.Attribute("HouseC1Checkout").Value.ToString();
                //CheckoutBatchDic["C2库房"] = asrsBatchCfgXE.Attribute("HouseC2Checkout").Value.ToString();
                //CheckinBatchHouseA = asrsBatchCfgXE.Attribute("HouseACheckin").Value.ToString();
                //CheckoutBatchHouseA = asrsBatchCfgXE.Attribute("HouseACheckout").Value.ToString();
                //CheckinBatchHouseB = asrsBatchCfgXE.Attribute("HouseBCheckin").Value.ToString();
                //CheckoutBatchHouseB = asrsBatchCfgXE.Attribute("HouseBCheckout").Value.ToString();

                //XElement asrsEnableXE = root.Element("sysSet").Element("AsrsEnableSet");
                //string str= asrsEnableXE.Attribute("HouseEnabledA").Value.ToString().ToUpper();
                //if(str == "TRUE")
                //{
                //    HouseEnabledA = true;
                //}
                //else
                //{
                //    HouseEnabledA = false;
                //}
                //str = asrsEnableXE.Attribute("HouseEnabledB").Value.ToString().ToUpper();
                //if (str == "TRUE")
                //{
                //    HouseEnabledB = true;
                //}
                //else
                //{
                //    HouseEnabledB = false;
                //}
                return(true);
            }
            catch (Exception ex)
            {
                reStr = ex.ToString();
                return(false);
            }
        }
Example #11
0
        public bool SetAreaColorCfg(string logicAreaName, Color color, ref string reStr)
        {
            StoreHouseLogicAreaModel logicArea = bllLogicArea.GetModelByName(logicAreaName);

            if (logicArea == null)
            {
                return(false);
            }
            if (this.areaColor.Keys.Contains(logicArea.StoreHouseLogicAreaID) == true)
            {
                foreach (Color col in this.areaColor.Values)
                {
                    if (col == color)
                    {
                        reStr = "已经存在相同库区颜色!";

                        return(false);
                    }
                }
            }
            this.areaColor[logicArea.StoreHouseLogicAreaID] = color;

            CtlDBAccess.BLL.SysCfgBll       sysCfgBll = new CtlDBAccess.BLL.SysCfgBll();
            CtlDBAccess.Model.SysCfgDBModel cfgModel  = sysCfgBll.GetModel(SysCfg.SysCfgModel.SysCfgFileName);
            XElement root = null;

            if (cfgModel == null)
            {
                reStr = "系统配置不存在!";
                return(false);
            }
            root = XElement.Parse(cfgModel.cfgFile);
            if (root == null)
            {
                reStr = "系统配置不存在!";
                return(false);
            }
            XElement houseAreaColorSet = root.Element("sysSet").Element("HouseAreaColorSet");

            if (houseAreaColorSet == null)
            {
                reStr = "系统逻辑库存颜色信息不存在!";
                return(false);
            }
            houseAreaColorSet.Elements().Remove();//移除所有节点
            foreach (KeyValuePair <long, Color> kv in this.areaColor)
            {
                long logicID = kv.Key;
                StoreHouseLogicAreaModel logicAreaModel = bllLogicArea.GetModel(logicID);
                if (logicAreaModel == null)
                {
                    continue;
                }
                string   rgb     = kv.Value.R + "," + kv.Value.G + "," + kv.Value.B;
                XElement element = new XElement("HouseArea", new XAttribute("houseAreaID", logicID), new XAttribute("areaName", logicAreaModel.StoreHouseAreaName));
                element.Value = rgb;
                houseAreaColorSet.Add(element);
            }
            if (cfgModel != null)
            {
                cfgModel.cfgFile = root.ToString();
                sysCfgBll.Update(cfgModel);
            }
            ShowAreaColor();
            RefreshPos(this.currHouseName, currRowth);
            return(true);
        }