Exemple #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CADS.Model.AttendanceRecordInfoList DataRowToModel(DataRow row)
 {
     CADS.Model.AttendanceRecordInfoList model = new CADS.Model.AttendanceRecordInfoList();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["PersonName"] != null)
         {
             model.PersonName = row["PersonName"].ToString();
         }
         if (row["PersonID"] != null)
         {
             model.PersonID = row["PersonID"].ToString();
         }
         if (row["PersonLeader"] != null)
         {
             model.PersonLeader = row["PersonLeader"].ToString();
         }
         if (row["TimeGo"] != null)
         {
             model.TimeGo = row["TimeGo"].ToString();
         }
         if (row["TimeEnd"] != null)
         {
             model.TimeEnd = row["TimeEnd"].ToString();
         }
         if (row["IsAbsent"] != null)
         {
             model.IsAbsent = row["IsAbsent"].ToString();
         }
         if (row["Reasons"] != null)
         {
             model.Reasons = row["Reasons"].ToString();
         }
         if (row["Description"] != null)
         {
             model.Description = row["Description"].ToString();
         }
         if (row["Mark"] != null)
         {
             model.Mark = row["Mark"].ToString();
         }
     }
     return(model);
 }
Exemple #2
0
        /// <summary>
        /// 数据操作
        /// </summary>
        /// <param name="Mess">区别编辑还是新增还是删除</param>
        private void OpreationDB(string Mess)
        {
            CADS.Model.AttendanceRecordInfoList AttendanceRecord = new CADS.Model.AttendanceRecordInfoList();

            AttendanceRecord.PersonName   = tbx_Name.Text.Trim();
            AttendanceRecord.PersonID     = tbx_ID.Text.Trim();
            AttendanceRecord.PersonLeader = tbx_Leader.Text.Trim();
            AttendanceRecord.TimeGo       = dtp_start.Value.ToString("yyyy-MM-dd HH:mm:ss");
            AttendanceRecord.IsAbsent     = cbx_IsAbsent.SelectedText.ToString();
            AttendanceRecord.Reasons      = tbx_Reasons.Text;
            AttendanceRecord.TimeEnd      = dtp_end.Value.ToString("yyyy-MM-dd HH:mm:ss");
            AttendanceRecord.Description  = tbx_descrip.Text;
            AttendanceRecord.Mark         = cbx_IsAbsent.SelectedText;//预留字段MARK这里用来保存预案处置结果


            string Error  = "";
            bool   Result = false;

            if (Mess == "添加")
            {
                Result = attendanceRecord.Add(AttendanceRecord);
            }
            if (Mess == "编辑")
            {
                AttendanceRecord.ID = Convert.ToInt32(infoList[0].ToString());
                Result = attendanceRecord.Update(AttendanceRecord);
            }
            if (Mess == "删除")
            {
                AttendanceRecord.ID = Convert.ToInt32(infoList[0].ToString());
                Result = attendanceRecord.Delete(AttendanceRecord.ID);
            }
            if (Result == true)
            {
                MessageBox.Show("设备信息" + Mess + "成功");
                ClearText(this.Content);
                this.Close();
            }
            else
            {
                MessageBox.Show("设备信息" + Mess + "失败,请稍后再试!");
                ClearText(this.Content);
            }
        }
Exemple #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CADS.Model.AttendanceRecordInfoList GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  ");
            strSql.Append(" ID,PersonName,PersonID,PersonLeader,TimeGo,TimeEnd,IsAbsent,Reasons,Description,Mark ");
            strSql.Append(" from AttendanceRecordInfoList ");
            strSql.Append(" where ID=" + ID + "");
            CADS.Model.AttendanceRecordInfoList model = new CADS.Model.AttendanceRecordInfoList();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CADS.Model.AttendanceRecordInfoList model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.PersonName != null)
            {
                strSql1.Append("PersonName,");
                strSql2.Append("'" + model.PersonName + "',");
            }
            if (model.PersonID != null)
            {
                strSql1.Append("PersonID,");
                strSql2.Append("'" + model.PersonID + "',");
            }
            if (model.PersonLeader != null)
            {
                strSql1.Append("PersonLeader,");
                strSql2.Append("'" + model.PersonLeader + "',");
            }
            if (model.TimeGo != null)
            {
                strSql1.Append("TimeGo,");
                strSql2.Append("'" + model.TimeGo + "',");
            }
            if (model.TimeEnd != null)
            {
                strSql1.Append("TimeEnd,");
                strSql2.Append("'" + model.TimeEnd + "',");
            }
            if (model.IsAbsent != null)
            {
                strSql1.Append("IsAbsent,");
                strSql2.Append("'" + model.IsAbsent + "',");
            }
            if (model.Reasons != null)
            {
                strSql1.Append("Reasons,");
                strSql2.Append("'" + model.Reasons + "',");
            }
            if (model.Description != null)
            {
                strSql1.Append("Description,");
                strSql2.Append("'" + model.Description + "',");
            }
            if (model.Mark != null)
            {
                strSql1.Append("Mark,");
                strSql2.Append("'" + model.Mark + "',");
            }
            strSql.Append("insert into AttendanceRecordInfoList(");
            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 = DbHelperOleDb.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CADS.Model.AttendanceRecordInfoList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AttendanceRecordInfoList set ");
            if (model.PersonName != null)
            {
                strSql.Append("PersonName='" + model.PersonName + "',");
            }
            else
            {
                strSql.Append("PersonName= null ,");
            }
            if (model.PersonID != null)
            {
                strSql.Append("PersonID='" + model.PersonID + "',");
            }
            else
            {
                strSql.Append("PersonID= null ,");
            }
            if (model.PersonLeader != null)
            {
                strSql.Append("PersonLeader='" + model.PersonLeader + "',");
            }
            else
            {
                strSql.Append("PersonLeader= null ,");
            }
            if (model.TimeGo != null)
            {
                strSql.Append("TimeGo='" + model.TimeGo + "',");
            }
            else
            {
                strSql.Append("TimeGo= null ,");
            }
            if (model.TimeEnd != null)
            {
                strSql.Append("TimeEnd='" + model.TimeEnd + "',");
            }
            else
            {
                strSql.Append("TimeEnd= null ,");
            }
            if (model.IsAbsent != null)
            {
                strSql.Append("IsAbsent='" + model.IsAbsent + "',");
            }
            else
            {
                strSql.Append("IsAbsent= null ,");
            }
            if (model.Reasons != null)
            {
                strSql.Append("Reasons='" + model.Reasons + "',");
            }
            else
            {
                strSql.Append("Reasons= null ,");
            }
            if (model.Description != null)
            {
                strSql.Append("Description='" + model.Description + "',");
            }
            else
            {
                strSql.Append("Description= null ,");
            }
            if (model.Mark != null)
            {
                strSql.Append("Mark='" + model.Mark + "',");
            }
            else
            {
                strSql.Append("Mark= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where ID=" + model.ID + "");
            int rowsAffected = DbHelperOleDb.ExecuteSql(strSql.ToString());

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