Example #1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void  Add(RelayTest.Model.ModelCOM_SETTINGS model)
 {
     try
     {
         Log.Info("BllCOM_SETTINGS->Add---START");
         ConnectionOpen();
         dal.SetDBAccess(GetDBAccess());
         dal.Add(model);
     }
     catch (Exception ex)
     {
         Log.Error("BllCOM_SETTINGS->Add---FAILED", ex);
         throw ex;
     }
     finally
     {
         ConnectionClose();
         Log.Info("BllCOM_SETTINGS->Add---finally");
     }
 }
Example #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">相应的数据实体</param>
 /// <returns>真表示有记录被更新,否表示没有记录被更新</returns>
 public bool Update(RelayTest.Model.ModelCOM_SETTINGS model)
 {
     try
     {
         Log.Info("BllCOM_SETTINGS->Update---START");
         ConnectionOpen();
         dal.SetDBAccess(GetDBAccess());
         return(dal.Update(model));
     }
     catch (Exception ex)
     {
         Log.Error("BllCOM_SETTINGS->Update---FAILED", ex);
         throw ex;
     }
     finally
     {
         ConnectionClose();
         Log.Info("BllCOM_SETTINGS->Update---finally");
     }
 }
Example #3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <RelayTest.Model.ModelCOM_SETTINGS> DataTableToList(DataTable dt)
        {
            try
            {
                Log.Info("BllCOM_SETTINGS->DataTableToList---START");
                ConnectionOpen();
                dal.SetDBAccess(GetDBAccess());
                List <RelayTest.Model.ModelCOM_SETTINGS> modelList = new List <RelayTest.Model.ModelCOM_SETTINGS>();
                int rowsCount = dt.Rows.Count;
                if (rowsCount > 0)
                {
                    RelayTest.Model.ModelCOM_SETTINGS model;
                    for (int n = 0; n < rowsCount; n++)
                    {
                        model = new RelayTest.Model.ModelCOM_SETTINGS();
                        model.F_WORKSTATION_ID = dt.Rows[n]["F_WORKSTATION_ID"].ToString();
                        model.F_COM_CODE       = dt.Rows[n]["F_COM_CODE"].ToString();
                        if (dt.Rows[n]["F_BAUDRATE"].ToString() != "")
                        {
                            model.F_BAUDRATE = decimal.Parse(dt.Rows[n]["F_BAUDRATE"].ToString());
                        }
                        if (dt.Rows[n]["F_DATABIT"].ToString() != "")
                        {
                            model.F_DATABIT = decimal.Parse(dt.Rows[n]["F_DATABIT"].ToString());
                        }
                        if (dt.Rows[n]["F_ODDEVENCHECK"].ToString() != "")
                        {
                            model.F_ODDEVENCHECK = decimal.Parse(dt.Rows[n]["F_ODDEVENCHECK"].ToString());
                        }
                        if (dt.Rows[n]["F_STOPBIT"].ToString() != "")
                        {
                            model.F_STOPBIT = decimal.Parse(dt.Rows[n]["F_STOPBIT"].ToString());
                        }
                        model.F_TYPE = dt.Rows[n]["F_TYPE"].ToString();
                        if (dt.Rows[n]["F_STREAMCONTROL"].ToString() != "")
                        {
                            model.F_STREAMCONTROL = decimal.Parse(dt.Rows[n]["F_STREAMCONTROL"].ToString());
                        }
                        if (dt.Rows[n]["F_CREATE_TIME"].ToString() != "")
                        {
                            model.F_CREATE_TIME = DateTime.Parse(dt.Rows[n]["F_CREATE_TIME"].ToString());
                        }
                        model.F_OPERATOR_ID = dt.Rows[n]["F_OPERATOR_ID"].ToString();
                        if (dt.Rows[n]["F_OPERATIONTIME"].ToString() != "")
                        {
                            model.F_OPERATIONTIME = DateTime.Parse(dt.Rows[n]["F_OPERATIONTIME"].ToString());
                        }
                        if (dt.Rows[n]["F_DEL"].ToString() != "")
                        {
                            model.F_DEL = decimal.Parse(dt.Rows[n]["F_DEL"].ToString());
                        }


                        modelList.Add(model);
                    }
                }
                return(modelList);
            }
            catch (Exception ex)
            {
                Log.Error("BllCOM_SETTINGS->DataTableToList---FAILED", ex);
                throw ex;
            }
            finally
            {
                ConnectionClose();
                Log.Info("BllCOM_SETTINGS->DataTableToList---finally");
            }
        }