Ejemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MesDBAccess.Model.BatteryFenrongCfgModel DataRowToModel(DataRow row)
 {
     MesDBAccess.Model.BatteryFenrongCfgModel model = new MesDBAccess.Model.BatteryFenrongCfgModel();
     if (row != null)
     {
         if (row["fenrongCfgID"] != null)
         {
             model.fenrongCfgID = row["fenrongCfgID"].ToString();
         }
         if (row["batteryCataCode"] != null)
         {
             model.batteryCataCode = row["batteryCataCode"].ToString();
         }
         if (row["fenrongZone"] != null)
         {
             model.fenrongZone = row["fenrongZone"].ToString();
         }
         if (row["mark"] != null)
         {
             model.mark = row["mark"].ToString();
         }
         if (row["tag1"] != null)
         {
             model.tag1 = row["tag1"].ToString();
         }
         if (row["tag2"] != null)
         {
             model.tag2 = row["tag2"].ToString();
         }
         if (row["tag3"] != null)
         {
             model.tag3 = row["tag3"].ToString();
         }
         if (row["tag4"] != null)
         {
             model.tag4 = row["tag4"].ToString();
         }
         if (row["tag5"] != null)
         {
             model.tag5 = row["tag5"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MesDBAccess.Model.BatteryFenrongCfgModel GetModel(string fenrongCfgID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" fenrongCfgID,batteryCataCode,fenrongZone,mark,tag1,tag2,tag3,tag4,tag5 ");
            strSql.Append(" from BatteryFenrongCfg ");
            strSql.Append(" where fenrongCfgID='" + fenrongCfgID + "' ");
            MesDBAccess.Model.BatteryFenrongCfgModel model = new MesDBAccess.Model.BatteryFenrongCfgModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        private void OnAddFenrongCfg()
        {
            string batteryCata = this.comboBox1.Text;
            string fenrongZone = this.comboBox2.Text;

            if (string.IsNullOrWhiteSpace(batteryCata) || string.IsNullOrWhiteSpace(fenrongZone))
            {
                MessageBox.Show("输入为空,请重新输入");
                return;
            }
            MesDBAccess.BLL.BatteryFenrongCfgBll fenrongCfgBll = new MesDBAccess.BLL.BatteryFenrongCfgBll();
            if (fenrongCfgBll.Exist(batteryCata, fenrongZone))
            {
                MessageBox.Show(string.Format("已经存在{0}-{1}配置", batteryCata, fenrongZone), "提示");
                return;
            }
            MesDBAccess.Model.BatteryFenrongCfgModel fenrongCfg = new MesDBAccess.Model.BatteryFenrongCfgModel();
            fenrongCfg.batteryCataCode = batteryCata;
            fenrongCfg.fenrongZone     = fenrongZone;
            fenrongCfg.fenrongCfgID    = System.Guid.NewGuid().ToString();
            fenrongCfg.mark            = textBox3.Text;
            fenrongCfgBll.Add(fenrongCfg);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(MesDBAccess.Model.BatteryFenrongCfgModel model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.fenrongCfgID != null)
            {
                strSql1.Append("fenrongCfgID,");
                strSql2.Append("'" + model.fenrongCfgID + "',");
            }
            if (model.batteryCataCode != null)
            {
                strSql1.Append("batteryCataCode,");
                strSql2.Append("'" + model.batteryCataCode + "',");
            }
            if (model.fenrongZone != null)
            {
                strSql1.Append("fenrongZone,");
                strSql2.Append("'" + model.fenrongZone + "',");
            }
            if (model.mark != null)
            {
                strSql1.Append("mark,");
                strSql2.Append("'" + model.mark + "',");
            }
            if (model.tag1 != null)
            {
                strSql1.Append("tag1,");
                strSql2.Append("'" + model.tag1 + "',");
            }
            if (model.tag2 != null)
            {
                strSql1.Append("tag2,");
                strSql2.Append("'" + model.tag2 + "',");
            }
            if (model.tag3 != null)
            {
                strSql1.Append("tag3,");
                strSql2.Append("'" + model.tag3 + "',");
            }
            if (model.tag4 != null)
            {
                strSql1.Append("tag4,");
                strSql2.Append("'" + model.tag4 + "',");
            }
            if (model.tag5 != null)
            {
                strSql1.Append("tag5,");
                strSql2.Append("'" + model.tag5 + "',");
            }
            strSql.Append("insert into BatteryFenrongCfg(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MesDBAccess.Model.BatteryFenrongCfgModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BatteryFenrongCfg set ");
            if (model.batteryCataCode != null)
            {
                strSql.Append("batteryCataCode='" + model.batteryCataCode + "',");
            }
            if (model.fenrongZone != null)
            {
                strSql.Append("fenrongZone='" + model.fenrongZone + "',");
            }
            if (model.mark != null)
            {
                strSql.Append("mark='" + model.mark + "',");
            }
            else
            {
                strSql.Append("mark= null ,");
            }
            if (model.tag1 != null)
            {
                strSql.Append("tag1='" + model.tag1 + "',");
            }
            else
            {
                strSql.Append("tag1= null ,");
            }
            if (model.tag2 != null)
            {
                strSql.Append("tag2='" + model.tag2 + "',");
            }
            else
            {
                strSql.Append("tag2= null ,");
            }
            if (model.tag3 != null)
            {
                strSql.Append("tag3='" + model.tag3 + "',");
            }
            else
            {
                strSql.Append("tag3= null ,");
            }
            if (model.tag4 != null)
            {
                strSql.Append("tag4='" + model.tag4 + "',");
            }
            else
            {
                strSql.Append("tag4= null ,");
            }
            if (model.tag5 != null)
            {
                strSql.Append("tag5='" + model.tag5 + "',");
            }
            else
            {
                strSql.Append("tag5= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where fenrongCfgID='" + model.fenrongCfgID + "' ");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }