Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.SMT_STAFF_DOOR model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SMT_STAFF_DOOR(");
            strSql.Append("STAFF_ID,DOOR_ID,IS_UPLOAD,UPLOAD_TIME,ADD_TIME,TIME_NUM)");
            strSql.Append(" values (");
            strSql.Append("@STAFF_ID,@DOOR_ID,@IS_UPLOAD,@UPLOAD_TIME,@ADD_TIME,@TIME_NUM)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@STAFF_ID",    SqlDbType.Decimal,   9),
                new SqlParameter("@DOOR_ID",     SqlDbType.Decimal,   9),
                new SqlParameter("@IS_UPLOAD",   SqlDbType.Bit,       1),
                new SqlParameter("@UPLOAD_TIME", SqlDbType.DateTime),
                new SqlParameter("@ADD_TIME",    SqlDbType.DateTime),
                new SqlParameter("@TIME_NUM",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.STAFF_ID;
            parameters[1].Value = model.DOOR_ID;
            parameters[2].Value = model.IS_UPLOAD;
            parameters[3].Value = model.UPLOAD_TIME;
            parameters[4].Value = model.ADD_TIME;
            parameters[5].Value = model.TIME_NUM;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.SMT_STAFF_DOOR GetModel(decimal STAFF_ID, decimal DOOR_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 STAFF_ID,DOOR_ID,IS_UPLOAD,UPLOAD_TIME,ADD_TIME,TIME_NUM from SMT_STAFF_DOOR ");
            strSql.Append(" where STAFF_ID=@STAFF_ID and DOOR_ID=@DOOR_ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@STAFF_ID", SqlDbType.Decimal, 9),
                new SqlParameter("@DOOR_ID",  SqlDbType.Decimal, 9)
            };
            parameters[0].Value = STAFF_ID;
            parameters[1].Value = DOOR_ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.SMT_STAFF_DOOR DataRowToModel(DataRow row)
 {
     Maticsoft.Model.SMT_STAFF_DOOR model = new Maticsoft.Model.SMT_STAFF_DOOR();
     if (row != null)
     {
         if (row["STAFF_ID"] != null && row["STAFF_ID"].ToString() != "")
         {
             model.STAFF_ID = decimal.Parse(row["STAFF_ID"].ToString());
         }
         if (row["DOOR_ID"] != null && row["DOOR_ID"].ToString() != "")
         {
             model.DOOR_ID = decimal.Parse(row["DOOR_ID"].ToString());
         }
         if (row["IS_UPLOAD"] != null && row["IS_UPLOAD"].ToString() != "")
         {
             if ((row["IS_UPLOAD"].ToString() == "1") || (row["IS_UPLOAD"].ToString().ToLower() == "true"))
             {
                 model.IS_UPLOAD = true;
             }
             else
             {
                 model.IS_UPLOAD = false;
             }
         }
         if (row["UPLOAD_TIME"] != null && row["UPLOAD_TIME"].ToString() != "")
         {
             model.UPLOAD_TIME = DateTime.Parse(row["UPLOAD_TIME"].ToString());
         }
         if (row["ADD_TIME"] != null && row["ADD_TIME"].ToString() != "")
         {
             model.ADD_TIME = DateTime.Parse(row["ADD_TIME"].ToString());
         }
         if (row["TIME_NUM"] != null && row["TIME_NUM"].ToString() != "")
         {
             model.TIME_NUM = int.Parse(row["TIME_NUM"].ToString());
         }
     }
     return(model);
 }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.SMT_STAFF_DOOR model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SMT_STAFF_DOOR set ");
            strSql.Append("IS_UPLOAD=@IS_UPLOAD,");
            strSql.Append("UPLOAD_TIME=@UPLOAD_TIME,");
            strSql.Append("ADD_TIME=@ADD_TIME,");
            strSql.Append("TIME_NUM=@TIME_NUM");
            strSql.Append(" where STAFF_ID=@STAFF_ID and DOOR_ID=@DOOR_ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@IS_UPLOAD",   SqlDbType.Bit,       1),
                new SqlParameter("@UPLOAD_TIME", SqlDbType.DateTime),
                new SqlParameter("@ADD_TIME",    SqlDbType.DateTime),
                new SqlParameter("@TIME_NUM",    SqlDbType.Int,       4),
                new SqlParameter("@STAFF_ID",    SqlDbType.Decimal,   9),
                new SqlParameter("@DOOR_ID",     SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.IS_UPLOAD;
            parameters[1].Value = model.UPLOAD_TIME;
            parameters[2].Value = model.ADD_TIME;
            parameters[3].Value = model.TIME_NUM;
            parameters[4].Value = model.STAFF_ID;
            parameters[5].Value = model.DOOR_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        private void DoSaveDoors(List <Maticsoft.Model.SMT_DOOR_INFO> doors, bool upload = false)
        {
            if (dtpStart.Value.Date > dtpEnd.Value.Date)
            {
                WinInfoHelper.ShowInfoWindow(this, "起始时间不能小于结束时间!");
                return;
            }
            int          timenum = 0;
            ComboBoxItem cbi     = (ComboBoxItem)cbTimeNum.SelectedItem;

            if (cbi.Tag is Maticsoft.Model.SMT_TIMESCALE_INFO)
            {
                Maticsoft.Model.SMT_TIMESCALE_INFO tsInfo = (Maticsoft.Model.SMT_TIMESCALE_INFO)cbi.Tag;
                timenum = tsInfo.TIME_NO;
            }
            else
            {
                timenum = 1;
            }

            CtrlWaiting ctrlWaiting = new CtrlWaiting("正在保存...", () =>
            {
                try
                {
                    Maticsoft.BLL.SMT_STAFF_DOOR sdBLL = new Maticsoft.BLL.SMT_STAFF_DOOR();
                    var sdList = sdBLL.GetModelList("STAFF_ID=" + staffInfo.ID);
                    List <Maticsoft.Model.SMT_DOOR_INFO> tempDoors = new List <Maticsoft.Model.SMT_DOOR_INFO>();
                    tempDoors.AddRange(doors);
                    foreach (var item in sdList)
                    {
                        var sc = doors.Find(m => m.ID == item.DOOR_ID);
                        if (sc == null)                                //权限删除
                        {
                            sdBLL.Delete(item.STAFF_ID, item.DOOR_ID); //删除权限
                        }
                        else
                        {
                            item.TIME_NUM  = timenum;
                            item.IS_UPLOAD = false;
                            sdBLL.Update(item);
                            tempDoors.Remove(sc);
                        }
                    }
                    foreach (var item in tempDoors) //添加的权限
                    {
                        Maticsoft.Model.SMT_STAFF_DOOR newSd = new Maticsoft.Model.SMT_STAFF_DOOR();
                        newSd.ADD_TIME    = DateTime.Now;
                        newSd.DOOR_ID     = item.ID;
                        newSd.IS_UPLOAD   = false;
                        newSd.UPLOAD_TIME = DateTime.Now;
                        newSd.STAFF_ID    = staffInfo.ID;
                        newSd.TIME_NUM    = timenum;

                        sdBLL.Add(newSd);
                    }
                    if (staffInfo.VALID_STARTTIME != dtpStart.Value || staffInfo.VALID_ENDTIME != dtpEnd.Value)
                    {
                        Maticsoft.BLL.SMT_STAFF_INFO staffBll = new Maticsoft.BLL.SMT_STAFF_INFO();
                        staffInfo.VALID_STARTTIME             = dtpStart.Value.Date;
                        staffInfo.VALID_ENDTIME = dtpEnd.Value.Date + new TimeSpan(23, 59, 59);
                        staffBll.Update(staffInfo);
                    }

                    if (upload)
                    {
                        string errMsg;
                        bool ret = UploadPrivate.Upload(staffInfo, out errMsg);
                        if (ret && errMsg != "")
                        {
                            WinInfoHelper.ShowInfoWindow(this, "上传权限存在异常:" + errMsg);
                            log.Warn("上传权限存在异常:" + errMsg);
                            return;
                        }
                        else if (!ret)
                        {
                            return;
                        }
                        else
                        {
                            WinInfoHelper.ShowInfoWindow(null, "上传权限结束!");
                        }
                    }
                    this.Invoke(new Action(() =>
                    {
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }));
                }
                catch (System.Exception ex)
                {
                    log.Error("保存异常:", ex);
                    WinInfoHelper.ShowInfoWindow(this, "保存异常:" + ex.Message);
                }
            });

            ctrlWaiting.Show(this);
        }