Example #1
0
        private void AddData(Maticsoft.Model.SMT_TIMESCALE_INFO info)
        {
            DataGridViewRow row = new DataGridViewRow();

            row.CreateCells(dgvData,
                            info.TIME_NO,
                            info.TIME_NAME,
                            info.TIME_WEEK_DAY1,
                            info.TIME_WEEK_DAY2,
                            info.TIME_WEEK_DAY3,
                            info.TIME_WEEK_DAY4,
                            info.TIME_WEEK_DAY5,
                            info.TIME_WEEK_DAY6,
                            info.TIME_WEEK_DAY7,
                            info.TIME_RANGE_START1,
                            info.TIME_RANGE_END1,
                            info.TIME_RANGE_START2,
                            info.TIME_RANGE_END2,
                            info.TIME_RANGE_START3,
                            info.TIME_RANGE_END3,
                            info.TIME_NEXT_NO,
                            info.TIME_DATE_START.Date.ToString("yyyy-MM-dd"),
                            info.TIME_DATE_END.ToString("yyyy-MM-dd")
                            );
            row.Tag = info;
            dgvData.Rows.Add(row);
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public decimal Add(Maticsoft.Model.SMT_TIMESCALE_INFO model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SMT_TIMESCALE_INFO(");
            strSql.Append("TIME_NO,TIME_NAME,TIME_WEEK_DAY1,TIME_WEEK_DAY2,TIME_WEEK_DAY3,TIME_WEEK_DAY4,TIME_WEEK_DAY5,TIME_WEEK_DAY6,TIME_WEEK_DAY7,TIME_DATE_START,TIME_DATE_END,TIME_RANGE_START1,TIME_RANGE_END1,TIME_RANGE_START2,TIME_RANGE_END2,TIME_RANGE_START3,TIME_RANGE_END3,TIME_NEXT_NO)");
            strSql.Append(" values (");
            strSql.Append("@TIME_NO,@TIME_NAME,@TIME_WEEK_DAY1,@TIME_WEEK_DAY2,@TIME_WEEK_DAY3,@TIME_WEEK_DAY4,@TIME_WEEK_DAY5,@TIME_WEEK_DAY6,@TIME_WEEK_DAY7,@TIME_DATE_START,@TIME_DATE_END,@TIME_RANGE_START1,@TIME_RANGE_END1,@TIME_RANGE_START2,@TIME_RANGE_END2,@TIME_RANGE_START3,@TIME_RANGE_END3,@TIME_NEXT_NO)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TIME_NO",           SqlDbType.Int,        4),
                new SqlParameter("@TIME_NAME",         SqlDbType.NVarChar, 100),
                new SqlParameter("@TIME_WEEK_DAY1",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY2",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY3",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY4",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY5",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY6",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY7",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_DATE_START",   SqlDbType.Date,       3),
                new SqlParameter("@TIME_DATE_END",     SqlDbType.Date,       3),
                new SqlParameter("@TIME_RANGE_START1", SqlDbType.Time,       5),
                new SqlParameter("@TIME_RANGE_END1",   SqlDbType.Time,       5),
                new SqlParameter("@TIME_RANGE_START2", SqlDbType.Time,       5),
                new SqlParameter("@TIME_RANGE_END2",   SqlDbType.Time,       5),
                new SqlParameter("@TIME_RANGE_START3", SqlDbType.Time,       5),
                new SqlParameter("@TIME_RANGE_END3",   SqlDbType.Time,       5),
                new SqlParameter("@TIME_NEXT_NO",      SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.TIME_NO;
            parameters[1].Value  = model.TIME_NAME;
            parameters[2].Value  = model.TIME_WEEK_DAY1;
            parameters[3].Value  = model.TIME_WEEK_DAY2;
            parameters[4].Value  = model.TIME_WEEK_DAY3;
            parameters[5].Value  = model.TIME_WEEK_DAY4;
            parameters[6].Value  = model.TIME_WEEK_DAY5;
            parameters[7].Value  = model.TIME_WEEK_DAY6;
            parameters[8].Value  = model.TIME_WEEK_DAY7;
            parameters[9].Value  = model.TIME_DATE_START;
            parameters[10].Value = model.TIME_DATE_END;
            parameters[11].Value = model.TIME_RANGE_START1;
            parameters[12].Value = model.TIME_RANGE_END1;
            parameters[13].Value = model.TIME_RANGE_START2;
            parameters[14].Value = model.TIME_RANGE_END2;
            parameters[15].Value = model.TIME_RANGE_START3;
            parameters[16].Value = model.TIME_RANGE_END3;
            parameters[17].Value = model.TIME_NEXT_NO;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToDecimal(obj));
            }
        }
Example #3
0
        public static TimeScaleNum ToTimeScale(Maticsoft.Model.SMT_TIMESCALE_INFO tsInfo)
        {
            TimeScaleNum tsNum = new TimeScaleNum();

            tsNum.Num               = tsInfo.TIME_NO;
            tsNum.NextNum           = tsInfo.TIME_NEXT_NO;
            tsNum.startDate         = tsInfo.TIME_DATE_START;
            tsNum.endDate           = tsInfo.TIME_DATE_END;
            tsNum.weekDaysEnable[0] = tsInfo.TIME_WEEK_DAY1;
            tsNum.weekDaysEnable[1] = tsInfo.TIME_WEEK_DAY2;
            tsNum.weekDaysEnable[2] = tsInfo.TIME_WEEK_DAY3;
            tsNum.weekDaysEnable[3] = tsInfo.TIME_WEEK_DAY4;
            tsNum.weekDaysEnable[4] = tsInfo.TIME_WEEK_DAY5;
            tsNum.weekDaysEnable[5] = tsInfo.TIME_WEEK_DAY6;
            tsNum.weekDaysEnable[6] = tsInfo.TIME_WEEK_DAY7;
            tsNum.timeScales.Add(new TimeScale()
            {
                start = tsInfo.TIME_RANGE_START1,
                end   = tsInfo.TIME_RANGE_END1
            });
            tsNum.timeScales.Add(new TimeScale()
            {
                start = tsInfo.TIME_RANGE_START2,
                end   = tsInfo.TIME_RANGE_END2
            });
            tsNum.timeScales.Add(new TimeScale()
            {
                start = tsInfo.TIME_RANGE_START3,
                end   = tsInfo.TIME_RANGE_END3
            });
            return(tsNum);
        }
Example #4
0
 public FrmInOutTimeEditor(Maticsoft.Model.SMT_TIMESCALE_INFO tsInfo = null, bool isread = false)
 {
     InitializeComponent();
     _timeScaleInfo = tsInfo;
     if (tsInfo != null && isread)
     {
         this.Text       = "查看时区信息";
         btnOk.Visible   = false;
         btnCancel.Text  = "关闭";
         tbName.ReadOnly = true;
         dtpStartDate.IsInputReadOnly = true;
         dtpEndDate.IsInputReadOnly   = true;
         cbTimeNo.Enabled             = false;
         cbNextTimeNo.Enabled         = false;
         foreach (Control item in groupPanel1.Controls)
         {
             item.Enabled = false;
         }
         foreach (Control item in groupPanel2.Controls)
         {
             if (item is DevComponents.Editors.DateTimeAdv.DateTimeInput)
             {
                 ((DevComponents.Editors.DateTimeAdv.DateTimeInput)item).IsInputReadOnly = true;
             }
         }
     }
     else if (tsInfo != null)
     {
         this.Text = "编辑时区信息";
     }
     else
     {
         this.Text = "新建时区信息";
     }
 }
Example #5
0
        private void cbTimeNum_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBoxItem item = (ComboBoxItem)cbTimeNum.SelectedItem;

            if (item.Tag == null || item.Tag.ToString() == "")
            {
                this.dtpStart.Value = this.staffInfo.VALID_STARTTIME;
                this.dtpEnd.Value   = this.staffInfo.VALID_ENDTIME;
            }
            else
            {
                Maticsoft.Model.SMT_TIMESCALE_INFO tsInfo = (Maticsoft.Model.SMT_TIMESCALE_INFO)item.Tag;
                this.dtpStart.Value = tsInfo.TIME_DATE_START;
                this.dtpEnd.Value   = tsInfo.TIME_DATE_END;
            }
        }
Example #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.SMT_TIMESCALE_INFO GetModel(decimal ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,TIME_NO,TIME_NAME,TIME_WEEK_DAY1,TIME_WEEK_DAY2,TIME_WEEK_DAY3,TIME_WEEK_DAY4,TIME_WEEK_DAY5,TIME_WEEK_DAY6,TIME_WEEK_DAY7,TIME_DATE_START,TIME_DATE_END,TIME_RANGE_START1,TIME_RANGE_END1,TIME_RANGE_START2,TIME_RANGE_END2,TIME_RANGE_START3,TIME_RANGE_END3,TIME_NEXT_NO from SMT_TIMESCALE_INFO ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Decimal)
            };
            parameters[0].Value = ID;

            Maticsoft.Model.SMT_TIMESCALE_INFO model = new Maticsoft.Model.SMT_TIMESCALE_INFO();
            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 #7
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);
        }
Example #8
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.SMT_TIMESCALE_INFO DataRowToModel(DataRow row)
 {
     Maticsoft.Model.SMT_TIMESCALE_INFO model = new Maticsoft.Model.SMT_TIMESCALE_INFO();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = decimal.Parse(row["ID"].ToString());
         }
         if (row["TIME_NO"] != null && row["TIME_NO"].ToString() != "")
         {
             model.TIME_NO = int.Parse(row["TIME_NO"].ToString());
         }
         if (row["TIME_NAME"] != null)
         {
             model.TIME_NAME = row["TIME_NAME"].ToString();
         }
         if (row["TIME_WEEK_DAY1"] != null && row["TIME_WEEK_DAY1"].ToString() != "")
         {
             if ((row["TIME_WEEK_DAY1"].ToString() == "1") || (row["TIME_WEEK_DAY1"].ToString().ToLower() == "true"))
             {
                 model.TIME_WEEK_DAY1 = true;
             }
             else
             {
                 model.TIME_WEEK_DAY1 = false;
             }
         }
         if (row["TIME_WEEK_DAY2"] != null && row["TIME_WEEK_DAY2"].ToString() != "")
         {
             if ((row["TIME_WEEK_DAY2"].ToString() == "1") || (row["TIME_WEEK_DAY2"].ToString().ToLower() == "true"))
             {
                 model.TIME_WEEK_DAY2 = true;
             }
             else
             {
                 model.TIME_WEEK_DAY2 = false;
             }
         }
         if (row["TIME_WEEK_DAY3"] != null && row["TIME_WEEK_DAY3"].ToString() != "")
         {
             if ((row["TIME_WEEK_DAY3"].ToString() == "1") || (row["TIME_WEEK_DAY3"].ToString().ToLower() == "true"))
             {
                 model.TIME_WEEK_DAY3 = true;
             }
             else
             {
                 model.TIME_WEEK_DAY3 = false;
             }
         }
         if (row["TIME_WEEK_DAY4"] != null && row["TIME_WEEK_DAY4"].ToString() != "")
         {
             if ((row["TIME_WEEK_DAY4"].ToString() == "1") || (row["TIME_WEEK_DAY4"].ToString().ToLower() == "true"))
             {
                 model.TIME_WEEK_DAY4 = true;
             }
             else
             {
                 model.TIME_WEEK_DAY4 = false;
             }
         }
         if (row["TIME_WEEK_DAY5"] != null && row["TIME_WEEK_DAY5"].ToString() != "")
         {
             if ((row["TIME_WEEK_DAY5"].ToString() == "1") || (row["TIME_WEEK_DAY5"].ToString().ToLower() == "true"))
             {
                 model.TIME_WEEK_DAY5 = true;
             }
             else
             {
                 model.TIME_WEEK_DAY5 = false;
             }
         }
         if (row["TIME_WEEK_DAY6"] != null && row["TIME_WEEK_DAY6"].ToString() != "")
         {
             if ((row["TIME_WEEK_DAY6"].ToString() == "1") || (row["TIME_WEEK_DAY6"].ToString().ToLower() == "true"))
             {
                 model.TIME_WEEK_DAY6 = true;
             }
             else
             {
                 model.TIME_WEEK_DAY6 = false;
             }
         }
         if (row["TIME_WEEK_DAY7"] != null && row["TIME_WEEK_DAY7"].ToString() != "")
         {
             if ((row["TIME_WEEK_DAY7"].ToString() == "1") || (row["TIME_WEEK_DAY7"].ToString().ToLower() == "true"))
             {
                 model.TIME_WEEK_DAY7 = true;
             }
             else
             {
                 model.TIME_WEEK_DAY7 = false;
             }
         }
         if (row["TIME_DATE_START"] != null && row["TIME_DATE_START"].ToString() != "")
         {
             model.TIME_DATE_START = DateTime.Parse(row["TIME_DATE_START"].ToString());
         }
         if (row["TIME_DATE_END"] != null && row["TIME_DATE_END"].ToString() != "")
         {
             model.TIME_DATE_END = DateTime.Parse(row["TIME_DATE_END"].ToString());
         }
         if (row["TIME_RANGE_START1"] != null && row["TIME_RANGE_START1"].ToString() != "")
         {
             model.TIME_RANGE_START1 = TimeSpan.Parse(row["TIME_RANGE_START1"].ToString());
         }
         if (row["TIME_RANGE_END1"] != null && row["TIME_RANGE_END1"].ToString() != "")
         {
             model.TIME_RANGE_END1 = TimeSpan.Parse(row["TIME_RANGE_END1"].ToString());
         }
         if (row["TIME_RANGE_START2"] != null && row["TIME_RANGE_START2"].ToString() != "")
         {
             model.TIME_RANGE_START2 = TimeSpan.Parse(row["TIME_RANGE_START2"].ToString());
         }
         if (row["TIME_RANGE_END2"] != null && row["TIME_RANGE_END2"].ToString() != "")
         {
             model.TIME_RANGE_END2 = TimeSpan.Parse(row["TIME_RANGE_END2"].ToString());
         }
         if (row["TIME_RANGE_START3"] != null && row["TIME_RANGE_START3"].ToString() != "")
         {
             model.TIME_RANGE_START3 = TimeSpan.Parse(row["TIME_RANGE_START3"].ToString());
         }
         if (row["TIME_RANGE_END3"] != null && row["TIME_RANGE_END3"].ToString() != "")
         {
             model.TIME_RANGE_END3 = TimeSpan.Parse(row["TIME_RANGE_END3"].ToString());
         }
         if (row["TIME_NEXT_NO"] != null && row["TIME_NEXT_NO"].ToString() != "")
         {
             model.TIME_NEXT_NO = int.Parse(row["TIME_NEXT_NO"].ToString());
         }
     }
     return(model);
 }
Example #9
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.SMT_TIMESCALE_INFO model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SMT_TIMESCALE_INFO set ");
            strSql.Append("TIME_NAME=@TIME_NAME,");
            strSql.Append("TIME_WEEK_DAY1=@TIME_WEEK_DAY1,");
            strSql.Append("TIME_WEEK_DAY2=@TIME_WEEK_DAY2,");
            strSql.Append("TIME_WEEK_DAY3=@TIME_WEEK_DAY3,");
            strSql.Append("TIME_WEEK_DAY4=@TIME_WEEK_DAY4,");
            strSql.Append("TIME_WEEK_DAY5=@TIME_WEEK_DAY5,");
            strSql.Append("TIME_WEEK_DAY6=@TIME_WEEK_DAY6,");
            strSql.Append("TIME_WEEK_DAY7=@TIME_WEEK_DAY7,");
            strSql.Append("TIME_DATE_START=@TIME_DATE_START,");
            strSql.Append("TIME_DATE_END=@TIME_DATE_END,");
            strSql.Append("TIME_RANGE_START1=@TIME_RANGE_START1,");
            strSql.Append("TIME_RANGE_END1=@TIME_RANGE_END1,");
            strSql.Append("TIME_RANGE_START2=@TIME_RANGE_START2,");
            strSql.Append("TIME_RANGE_END2=@TIME_RANGE_END2,");
            strSql.Append("TIME_RANGE_START3=@TIME_RANGE_START3,");
            strSql.Append("TIME_RANGE_END3=@TIME_RANGE_END3,");
            strSql.Append("TIME_NEXT_NO=@TIME_NEXT_NO");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TIME_NAME",         SqlDbType.NVarChar, 100),
                new SqlParameter("@TIME_WEEK_DAY1",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY2",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY3",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY4",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY5",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY6",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_WEEK_DAY7",    SqlDbType.Bit,        1),
                new SqlParameter("@TIME_DATE_START",   SqlDbType.Date,       3),
                new SqlParameter("@TIME_DATE_END",     SqlDbType.Date,       3),
                new SqlParameter("@TIME_RANGE_START1", SqlDbType.Time,       5),
                new SqlParameter("@TIME_RANGE_END1",   SqlDbType.Time,       5),
                new SqlParameter("@TIME_RANGE_START2", SqlDbType.Time,       5),
                new SqlParameter("@TIME_RANGE_END2",   SqlDbType.Time,       5),
                new SqlParameter("@TIME_RANGE_START3", SqlDbType.Time,       5),
                new SqlParameter("@TIME_RANGE_END3",   SqlDbType.Time,       5),
                new SqlParameter("@TIME_NEXT_NO",      SqlDbType.Int,        4),
                new SqlParameter("@ID",                SqlDbType.Decimal,    9),
                new SqlParameter("@TIME_NO",           SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.TIME_NAME;
            parameters[1].Value  = model.TIME_WEEK_DAY1;
            parameters[2].Value  = model.TIME_WEEK_DAY2;
            parameters[3].Value  = model.TIME_WEEK_DAY3;
            parameters[4].Value  = model.TIME_WEEK_DAY4;
            parameters[5].Value  = model.TIME_WEEK_DAY5;
            parameters[6].Value  = model.TIME_WEEK_DAY6;
            parameters[7].Value  = model.TIME_WEEK_DAY7;
            parameters[8].Value  = model.TIME_DATE_START;
            parameters[9].Value  = model.TIME_DATE_END;
            parameters[10].Value = model.TIME_RANGE_START1;
            parameters[11].Value = model.TIME_RANGE_END1;
            parameters[12].Value = model.TIME_RANGE_START2;
            parameters[13].Value = model.TIME_RANGE_END2;
            parameters[14].Value = model.TIME_RANGE_START3;
            parameters[15].Value = model.TIME_RANGE_END3;
            parameters[16].Value = model.TIME_NEXT_NO;
            parameters[17].Value = model.ID;
            parameters[18].Value = model.TIME_NO;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #10
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!CheckInput())
            {
                return;
            }
            if (_timeScaleInfo == null)
            {
                _timeScaleInfo    = new Maticsoft.Model.SMT_TIMESCALE_INFO();
                _timeScaleInfo.ID = -1;
            }
            _timeScaleInfo.TIME_NAME         = tbName.Text.Trim();
            _timeScaleInfo.TIME_NO           = (int)cbTimeNo.SelectedItem;
            _timeScaleInfo.TIME_NEXT_NO      = (int)cbNextTimeNo.SelectedItem;
            _timeScaleInfo.TIME_DATE_START   = dtpStartDate.Value.Date;
            _timeScaleInfo.TIME_DATE_END     = dtpEndDate.Value.Date;
            _timeScaleInfo.TIME_WEEK_DAY1    = cbWeek1.Checked;
            _timeScaleInfo.TIME_WEEK_DAY2    = cbWeek2.Checked;
            _timeScaleInfo.TIME_WEEK_DAY3    = cbWeek3.Checked;
            _timeScaleInfo.TIME_WEEK_DAY4    = cbWeek4.Checked;
            _timeScaleInfo.TIME_WEEK_DAY5    = cbWeek5.Checked;
            _timeScaleInfo.TIME_WEEK_DAY6    = cbWeek6.Checked;
            _timeScaleInfo.TIME_WEEK_DAY7    = cbWeek7.Checked;
            _timeScaleInfo.TIME_RANGE_START1 = dtiTimeAreaStart1.Value.TimeOfDay;
            _timeScaleInfo.TIME_RANGE_END1   = dtiTimeAreaEnd1.Value.TimeOfDay;
            _timeScaleInfo.TIME_RANGE_START2 = dtiTimeAreaStart2.Value.TimeOfDay;
            _timeScaleInfo.TIME_RANGE_END2   = dtiTimeAreaEnd2.Value.TimeOfDay;
            _timeScaleInfo.TIME_RANGE_START3 = dtiTimeAreaStart3.Value.TimeOfDay;
            _timeScaleInfo.TIME_RANGE_END3   = dtiTimeAreaEnd3.Value.TimeOfDay;
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_TIMESCALE_INFO scBll = new Maticsoft.BLL.SMT_TIMESCALE_INFO();
                    if (_timeScaleInfo.ID == -1)
                    {
                        var ss = scBll.GetModelList("TIME_NO=" + _timeScaleInfo.TIME_NO);
                        if (ss.Count > 0)
                        {
                            WinInfoHelper.ShowInfoWindow(this, "已存在同一时区的规则!");
                            return;
                        }
                        _timeScaleInfo.ID = scBll.Add(_timeScaleInfo);
                        SmtLog.Info("配置", "添加时区,编号:" + _timeScaleInfo.TIME_NO + ",名称:" + _timeScaleInfo.TIME_NAME);
                    }
                    else
                    {
                        scBll.Update(_timeScaleInfo);
                        SmtLog.Info("配置", "更新时区,编号:" + _timeScaleInfo.TIME_NO + ",名称:" + _timeScaleInfo.TIME_NAME);
                    }
                    this.Invoke(new Action(() =>
                    {
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Close();
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "保存异常:" + ex.Message);
                    log.Error("保存异常:", ex);
                }
            });

            waiting.Show(this);
        }