Esempio n. 1
0
        public bool CheckGroupSignalStatus(SignalLightsStatus_sls_Info status, Guid groupId)
        {
            try
            {
                string strSQL;
                int count;
                List<SqlParameter> sqlparams = new List<SqlParameter>();
                if (groupId != null && groupId != Guid.Empty)
                {
                    strSQL = "SELECT COUNT(1) FROM SignalStatusGroup_ssg a WHERE ssg_cGroupID=@GroupId";
                    sqlparams.Add(SQLHelper.MakeInParam("@GroupId", SqlDbType.UniqueIdentifier, 0, groupId));
                    count = (int)(SQLHelper.ExecuteScalar(strSQL, sqlparams.ToArray()));
                    if (count == 0) return false;

                }
                strSQL = "SELECT COUNT(1) FROM SignalLightsStatus_sls a "
                    + "LEFT JOIN SignalStatusGroupItem_sgi b ON a.sls_cRecordID=b.sgi_cRecordID "
                    + "WHERE a.sls_cStatus=@Status ";
                sqlparams = new List<SqlParameter>();
                sqlparams.Add(SQLHelper.MakeInParam("@Status", SqlDbType.NVarChar, 100, status.sls_cStatus));
                if (status.sls_cRecordID != null && status.sls_cRecordID != Guid.Empty)
                {
                    strSQL += "AND a.sls_cRecordID<>@RecId ";
                    sqlparams.Add(SQLHelper.MakeInParam("@RecId", SqlDbType.UniqueIdentifier, 0, status.sls_cRecordID));
                }
                if (groupId == null || groupId == Guid.Empty)
                {
                    strSQL += "AND b.sgi_cGroupID IS NULL";
                }
                else
                {
                    strSQL += "AND b.sgi_cGroupID=@GroupId";
                    sqlparams.Add(SQLHelper.MakeInParam("@GroupId", SqlDbType.UniqueIdentifier, 0, groupId));
                }
                count = (int)(SQLHelper.ExecuteScalar(strSQL, sqlparams.ToArray()));
                if (count > 0) return false;
            }
            catch (Exception e)
            {
                return false;
            }
            return true;
        }
        private void SignalLightsStatusDetail_Load(object sender, EventArgs e)
        {
            _editInfo = this.BaseParam as SignalLightsStatus_sls_Info;

            if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Insert)
            {
                this.TabText = "新增 - " + this.Text;

                UserInputData insertInfo = new UserInputData();

                proUserData.SelectedObject = insertInfo;
            }
            else if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Update)
            {
                this.TabText = "查看 - " + this.Text;

                UserInputData showData = new UserInputData(_editInfo);

                proUserData.SelectedObject = showData;

            }
        }
Esempio n. 3
0
 private bool CheckSignalStatusInput(int srcPos)
 {
     SignalLightsStatus_sls_Info status = new SignalLightsStatus_sls_Info();
     if (srcPos >= 0 && srcPos < SignalStatusInfos.Count)
         status.sls_cRecordID = SignalStatusInfos[srcPos].sls_cRecordID;
     InputStatus(status);
     string errmsg = null;
     if (status.sls_cStatus == string.Empty) errmsg += (errmsg != null ? "\n" : "") + "請指定工程狀態";
     if (status.sls_cYellowLight == string.Empty) errmsg += (errmsg != null ? "\n" : "") + "請指定黃燈狀態";
     if (status.sls_cRedLight == string.Empty) errmsg += (errmsg != null ? "\n" : "") + "請指定紅燈狀態";
     if (status.sls_cGreenLight == string.Empty) errmsg += (errmsg != null ? "\n" : "") + "請指定綠燈狀態";
     if (status.sls_cAlertRing == string.Empty) errmsg += (errmsg != null ? "\n" : "") + "請指定警鈴狀態";
     if (srcPos < 0 || srcPos > SignalStatusInfos.Count) errmsg += (errmsg != null ? "\n" : "") + "請選擇要修改的記錄";
     else
     {
         bool err = false;
         for (int i = 0; i < SignalStatusInfos.Count; i++)
         {
             if (i != srcPos && SignalStatusInfos[i].sls_cStatus == status.sls_cStatus)
             {
                 errmsg += (errmsg != null ? "\n" : "") + "工程狀態不能重複";
                 err = true;
             }
             if (i != srcPos && SignalStatusInfos[i].sls_cRecordID == status.sls_cRecordID)
             {
                 errmsg += (errmsg != null ? "\n" : "") + "記錄ID已存在";
                 err = true;
             }
             if (err) break;
         }
     }
     if (errmsg != null)
     {
         MessageBox.Show(this, errmsg, "錯誤提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return false;
     }
     return true;
 }
Esempio n. 4
0
 private bool CheckSignalStatusDataForSave(SignalLightsStatus_sls_Info status, Guid groupId)
 {
     ReturnValueInfo rv = ((SignalLightsStatusBL)this._signalLightsStatusBL).CheckGroupSignalStatusNotExists(status, GroupInfos[_gpos].ssg_cGroupID);
     return rv.boolValue;
 }
        public void Copy(SignalLightsStatus_sls_Info src)
        {
            if (src == null) return;

            this.sls_cRecordID = src.sls_cRecordID;
            this.sls_cStatus = src.sls_cStatus;
            this.sls_cStatusName = src.sls_cStatusName;
            this.sls_cRedLight = src.sls_cRedLight;
            this.sls_cGreenLight = src.sls_cGreenLight;
            this.sls_cYellowLight = src.sls_cYellowLight;
            this.sls_cAlertRing = src.sls_cAlertRing;
            this.sls_iIntervalTime = src.sls_iIntervalTime;
            this.sls_iDurationTime = src.sls_iDurationTime;
            this.sls_dUpdateTime = src.sls_dUpdateTime;
        }
Esempio n. 6
0
        /// <summary>
        /// 工程狀態信號控制主檔
        /// </summary>
        /// <returns></returns>
        public List<SignalLightsStatus_sls_Info> GetSignalLightsStatusMaster(string machineID)
        {
            try
            {
                List<SignalLightsStatus_sls_Info> list = new List<SignalLightsStatus_sls_Info>();
                StringBuilder strSql = new StringBuilder();
                strSql.AppendLine("select ");
                strSql.AppendLine("sls_cRecordID,sls_cStatus,sls_cRedLight,sls_cGreenLight,sls_cYellowLight,sls_cAlertRing,sls_iIntervalTime,sls_iDurationTime,sls_dUpdateTime ");
                //strSql.AppendLine("from SignalLightsStatus_sls ");

                strSql.AppendLine("from MachineSignalStatusGroup_msg ");
                strSql.AppendLine("inner join SignalStatusGroupItem_sgi on sgi_cGroupID=msg_cGroupID ");
                strSql.AppendLine("inner join SignalLightsStatus_sls on sgi_cRecordID=sls_cRecordID ");
                strSql.AppendLine("where msg_cMachineID='"+machineID+"'");

                using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
                {
                    while (sdr.Read())
                    {
                        SignalLightsStatus_sls_Info model = new SignalLightsStatus_sls_Info();
                        if (sdr["sls_cRecordID"] != null && sdr["sls_cRecordID"].ToString() != "")
                        {
                            model.sls_cRecordID = new Guid(sdr["sls_cRecordID"].ToString());
                        }
                        if (sdr["sls_cStatus"] != null && sdr["sls_cStatus"].ToString() != "")
                        {
                            model.sls_cStatus = sdr["sls_cStatus"].ToString();
                        }
                        if (sdr["sls_cRedLight"] != null && sdr["sls_cRedLight"].ToString() != "")
                        {
                            model.sls_cRedLight = sdr["sls_cRedLight"].ToString();
                        }
                        if (sdr["sls_cGreenLight"] != null && sdr["sls_cGreenLight"].ToString() != "")
                        {
                            model.sls_cGreenLight = sdr["sls_cGreenLight"].ToString();
                        }
                        if (sdr["sls_cYellowLight"] != null && sdr["sls_cYellowLight"].ToString() != "")
                        {
                            model.sls_cYellowLight = sdr["sls_cYellowLight"].ToString();
                        }
                        if (sdr["sls_cAlertRing"] != null && sdr["sls_cAlertRing"].ToString() != "")
                        {
                            model.sls_cAlertRing = sdr["sls_cAlertRing"].ToString();
                        }
                        if (sdr["sls_iIntervalTime"] != null && sdr["sls_iIntervalTime"].ToString() != "")
                        {
                            model.sls_iIntervalTime = int.Parse(sdr["sls_iIntervalTime"].ToString());
                        }
                        if (sdr["sls_iDurationTime"] != null && sdr["sls_iDurationTime"].ToString() != "")
                        {
                            model.sls_iDurationTime = int.Parse(sdr["sls_iDurationTime"].ToString());
                        }
                        if (sdr["sls_dUpdateTime"] != null && sdr["sls_dUpdateTime"].ToString() != "")
                        {
                            model.sls_dUpdateTime = DateTime.Parse(sdr["sls_dUpdateTime"].ToString());
                        }
                        list.Add(model);
                    }
                }
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 7
0
        private void SysToolBar_OnItemNew_Click(object sender, EventArgs e)
        {
            MenuItem itemMenu = new MenuItem();

            itemMenu.Tag = typeof(SignalLightsStatusDetail).FullName;

            SignalLightsStatus_sls_Info insertInfo = new SignalLightsStatus_sls_Info();

            BaseForm form = this.ShowSubForm(itemMenu, this.BaseDockPanel, string.Empty, WeifenLuo.WinFormsUI.Docking.DockState.Document, insertInfo, Common.DefineConstantValue.EditStateEnum.OE_Insert);

            form.FromCloseCallBack += new CallBackDelegate(GetAllSignalLightsStatus);
        }
Esempio n. 8
0
 private bool SaveSignalStatusData(SignalLightsStatus_sls_Info status, bool update)
 {
     if (_gpos < 0 || _gpos >= GroupInfos.Count) return false;
     Common.DefineConstantValue.EditStateEnum EditMode = update ?
         Common.DefineConstantValue.EditStateEnum.OE_Update :
         Common.DefineConstantValue.EditStateEnum.OE_Insert;
     ReturnValueInfo rv = ((SignalLightsStatusBL)this._signalLightsStatusBL).SaveGroupSignalStatus(status, GroupInfos[_gpos].ssg_cGroupID, EditMode);
     return rv.boolValue;
 }
Esempio n. 9
0
        private string GetSignalLightsStatusSQL(SignalLightsStatus_sls_Info model)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();
            if (model.sls_cRecordID != null)
            {
                strSql1.Append("sls_cRecordID,");
                strSql2.Append("'" + model.sls_cRecordID + "',");
            }
            if (model.sls_cStatus != null)
            {
                strSql1.Append("sls_cStatus,");
                strSql2.Append("'" + model.sls_cStatus + "',");
            }
            if (model.sls_cRedLight != null)
            {
                strSql1.Append("sls_cRedLight,");
                strSql2.Append("'" + model.sls_cRedLight + "',");
            }
            if (model.sls_cGreenLight != null)
            {
                strSql1.Append("sls_cGreenLight,");
                strSql2.Append("'" + model.sls_cGreenLight + "',");
            }
            if (model.sls_cYellowLight != null)
            {
                strSql1.Append("sls_cYellowLight,");
                strSql2.Append("'" + model.sls_cYellowLight + "',");
            }
            if (model.sls_cAlertRing != null)
            {
                strSql1.Append("sls_cAlertRing,");
                strSql2.Append("'" + model.sls_cAlertRing + "',");
            }
            if (model.sls_iIntervalTime != null)
            {
                strSql1.Append("sls_iIntervalTime,");
                strSql2.Append("" + model.sls_iIntervalTime + ",");
            }
            if (model.sls_iDurationTime != null)
            {
                strSql1.Append("sls_iDurationTime,");
                strSql2.Append("" + model.sls_iDurationTime + ",");
            }
            if (model.sls_dUpdateTime != null)
            {
                strSql1.Append("sls_dUpdateTime,");
                strSql2.Append("'" + model.sls_dUpdateTime.Value.ToString(this._sqlLiteDatetimeFormat) + "',");
            }

            strSql.Append("insert into SignalLightsStatus_sls(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            return strSql.ToString();
        }
Esempio n. 10
0
        /// <summary>
        /// 工程狀態信號控制主檔
        /// </summary>
        /// <returns></returns>
        public List<SignalLightsStatus_sls_Info> GetSignalLightsStatusMaster()
        {
            try
            {
                List<SignalLightsStatus_sls_Info> list = new List<SignalLightsStatus_sls_Info>();
                StringBuilder strSql = new StringBuilder();
                strSql.AppendLine("select ");
                strSql.AppendLine("sls_cRecordID,sls_cStatus,sls_cRedLight,sls_cGreenLight,sls_cYellowLight,sls_cAlertRing,sls_iIntervalTime,sls_iDurationTime,sls_dUpdateTime ");
                strSql.AppendLine("from SignalLightsStatus_sls ");

                using (SQLiteDataReader sdr = DbHelperSQLite.ExecuteReader(strSql.ToString()))
                {
                    while (sdr.Read())
                    {
                        SignalLightsStatus_sls_Info model = new SignalLightsStatus_sls_Info();
                        if (sdr["sls_cRecordID"] != null && sdr["sls_cRecordID"].ToString() != "")
                        {
                            model.sls_cRecordID = new Guid(sdr["sls_cRecordID"].ToString());
                        }
                        if (sdr["sls_cStatus"] != null && sdr["sls_cStatus"].ToString() != "")
                        {
                            model.sls_cStatus = sdr["sls_cStatus"].ToString();
                        }
                        if (sdr["sls_cRedLight"] != null && sdr["sls_cRedLight"].ToString() != "")
                        {
                            model.sls_cRedLight = sdr["sls_cRedLight"].ToString();
                        }
                        if (sdr["sls_cGreenLight"] != null && sdr["sls_cGreenLight"].ToString() != "")
                        {
                            model.sls_cGreenLight = sdr["sls_cGreenLight"].ToString();
                        }
                        if (sdr["sls_cYellowLight"] != null && sdr["sls_cYellowLight"].ToString() != "")
                        {
                            model.sls_cYellowLight = sdr["sls_cYellowLight"].ToString();
                        }
                        if (sdr["sls_cAlertRing"] != null && sdr["sls_cAlertRing"].ToString() != "")
                        {
                            model.sls_cAlertRing = sdr["sls_cAlertRing"].ToString();
                        }
                        if (sdr["sls_iIntervalTime"] != null && sdr["sls_iIntervalTime"].ToString() != "")
                        {
                            model.sls_iIntervalTime = int.Parse(sdr["sls_iIntervalTime"].ToString());
                        }
                        if (sdr["sls_iDurationTime"] != null && sdr["sls_iDurationTime"].ToString() != "")
                        {
                            model.sls_iDurationTime = int.Parse(sdr["sls_iDurationTime"].ToString());
                        }

                        if (sdr["sls_dUpdateTime"] != null && sdr["sls_dUpdateTime"].ToString() != "")
                        {
                            model.sls_dUpdateTime = DateTime.Parse(sdr["sls_dUpdateTime"].ToString());
                        }

                        list.Add(model);
                    }
                }
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 11
0
        public bool UpdateRecord(SignalLightsStatus_sls_Info infoObject)
        {
            bool isSuccess = false;

            if (infoObject != null)
            {
                try
                {
                    using (MainDBDataContext db = new MainDBDataContext())
                    {
                        SignalLightsStatus_sls updateData = db.SignalLightsStatus_sls.FirstOrDefault(t => t.sls_cRecordID == infoObject.sls_cRecordID);

                        if (updateData != null)
                        {
                            updateData.sls_cStatus = infoObject.sls_cStatus;

                            updateData.sls_cRedLight = infoObject.sls_cRedLight;

                            updateData.sls_cGreenLight = infoObject.sls_cGreenLight;

                            updateData.sls_cYellowLight = infoObject.sls_cYellowLight;

                            updateData.sls_cAlertRing = infoObject.sls_cAlertRing;

                            updateData.sls_iIntervalTime = infoObject.sls_iIntervalTime;

                            updateData.sls_iDurationTime = infoObject.sls_iDurationTime;

                            db.SubmitChanges();

                            isSuccess = true;
                        }
                    }
                }
                catch (Exception Ex)
                {

                    throw Ex;
                }
            }

            return isSuccess;
        }
Esempio n. 12
0
        public bool UpdateGroupSignalStatus(SignalLightsStatus_sls_Info status)
        {
            if (status.sls_cRecordID == null || status.sls_cRecordID == Guid.Empty)
            {
                return false;
            }
            SqlConnection cn = null;
            SqlCommand cmd = null;
            SqlTransaction trans = null;
            try
            {
                cn = new SqlConnection(SQLHelper.ConnectionString);
                if (cn.State == ConnectionState.Closed) cn.Open();
                trans = cn.BeginTransaction();

                string strSQL = "UPDATE dbo.SignalLightsStatus_sls SET " +
                    "sls_cStatus=@Status,sls_cRedLight=@Red,sls_cGreenLight=@Green,"+
                    "sls_cYellowLight=@Yellow,sls_cAlertRing=@Alert,sls_iIntervalTime=@Interval,"+
                    "sls_iDurationTime=@Duration,sls_dUpdateTime=@Update "+
                    "WHERE sls_cRecordID=@Id";
                List<SqlParameter> sqlparams = new List<SqlParameter>();
                sqlparams.Add(SQLHelper.MakeInParam("@Status", SqlDbType.NVarChar, 100, status.sls_cStatus));
                sqlparams.Add(SQLHelper.MakeInParam("@Red", SqlDbType.NVarChar, 10, status.sls_cRedLight));
                sqlparams.Add(SQLHelper.MakeInParam("@Green", SqlDbType.NVarChar, 10, status.sls_cGreenLight));
                sqlparams.Add(SQLHelper.MakeInParam("@Yellow", SqlDbType.NVarChar, 10, status.sls_cYellowLight));
                sqlparams.Add(SQLHelper.MakeInParam("@Alert", SqlDbType.NVarChar, 10, status.sls_cAlertRing));
                sqlparams.Add(SQLHelper.MakeInParam("@Interval", SqlDbType.Int, 0, status.sls_iIntervalTime));
                sqlparams.Add(SQLHelper.MakeInParam("@Duration", SqlDbType.Int, 0, status.sls_iDurationTime));
                sqlparams.Add(SQLHelper.MakeInParam("@Update", SqlDbType.DateTime, 0, DateTime.Now));
                sqlparams.Add(SQLHelper.MakeInParam("@Id", SqlDbType.UniqueIdentifier, 0, status.sls_cRecordID));
                int rowsAffected = SQLHelper.ExecuteNonQuery(strSQL, sqlparams.ToArray());
                if (rowsAffected > 0)//当更新的行数小于等于0时,插入失败
                {
                    trans.Commit();
                    status.sls_dUpdateTime = DateTime.Now;
                    return true;
                }
                trans.Rollback();
                return false;
            }
            catch (Exception e)
            {
                if (trans != null) trans.Rollback();
                return false;
            }
            finally
            {
                if (trans != null) trans.Dispose();
                if (cmd != null) cmd.Dispose();
                if (cn.State == ConnectionState.Open) cn.Close();
                if (cn != null) cn.Dispose();
            }
        }
Esempio n. 13
0
        public List<SignalLightsStatus_sls_Info> SearchGroupSignalItems(Guid groupId)
        {
            List<SignalLightsStatus_sls_Info> list = new List<SignalLightsStatus_sls_Info>();
            try
            {
                string strSQL = "SELECT a.*,b.sgi_cGroupID FROM SignalLightsStatus_sls a "
                    + "LEFT JOIN SignalStatusGroupItem_sgi b ON a.sls_cRecordID=b.sgi_cRecordID ";
                List<SqlParameter> sqlparams = new List<SqlParameter>();
                if (groupId == null || groupId == Guid.Empty)
                {
                    strSQL += "WHERE b.sgi_cGroupID IS NULL ";
                }
                else
                {
                    strSQL += "WHERE b.sgi_cGroupID=@GroupId ";
                    sqlparams.Add(SQLHelper.MakeInParam("@GroupId", SqlDbType.UniqueIdentifier, 0, groupId));
                }
                strSQL += "ORDER BY a.sls_dUpdateTime";

                DataSet data = SQLHelper.ExecuteDataset(strSQL, sqlparams.ToArray());
                if (data.Tables.Count > 0 && data.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in data.Tables[0].Rows)
                    {

                        SignalLightsStatus_sls_Info sls = new SignalLightsStatus_sls_Info();
                        sls.sls_cRecordID = row.IsNull("sls_cRecordID") ? Guid.Empty : (Guid)row["sls_cRecordID"];
                        sls.sls_cStatus = Convert.ToString(row["sls_cStatus"]);
                        sls.sls_cYellowLight = Convert.ToString(row["sls_cYellowLight"]);
                        sls.sls_cRedLight = Convert.ToString(row["sls_cRedLight"]);
                        sls.sls_cGreenLight = Convert.ToString(row["sls_cGreenLight"]);
                        sls.sls_cAlertRing = Convert.ToString(row["sls_cAlertRing"]);
                        sls.sls_iIntervalTime = Convert.ToInt32(row["sls_iIntervalTime"]);
                        sls.sls_iDurationTime = Convert.ToInt32(row["sls_iDurationTime"]);
                        sls.sls_dUpdateTime = Convert.ToDateTime(row["sls_dUpdateTime"]);
                        list.Add(sls);
                    }
                    data.Clear();
                }

            }
            catch (Exception e)
            {
            }
            return list;
        }
Esempio n. 14
0
        public bool InsertRecord(SignalLightsStatus_sls_Info infoObject)
        {
            bool isSuccess = false;

            if (infoObject != null)
            {
                try
                {
                    using (MainDBDataContext db = new MainDBDataContext())
                    {
                        SignalLightsStatus_sls insertData = Common.General.CopyObjectValue<SignalLightsStatus_sls_Info, SignalLightsStatus_sls>(infoObject);

                        db.SignalLightsStatus_sls.InsertOnSubmit(insertData);

                        db.SubmitChanges();

                        isSuccess = true;
                    }
                }
                catch (Exception Ex)
                {

                    throw Ex;
                }
            }

            return isSuccess;
        }
Esempio n. 15
0
        public bool InsertGroupSignalStatus(SignalLightsStatus_sls_Info status, Guid groupId)
        {
            if (status.sls_cRecordID == null || status.sls_cRecordID == Guid.Empty)
            {
                status.sls_cRecordID = Guid.NewGuid();
            }
            SqlConnection cn = null;
            SqlCommand cmd = null;
            SqlTransaction trans = null;
            try
            {
                cn = new SqlConnection(SQLHelper.ConnectionString);
                if (cn.State == ConnectionState.Closed) cn.Open();
                trans = cn.BeginTransaction();

                string strSQL = "INSERT INTO dbo.SignalLightsStatus_sls("+
                    "sls_cRecordID,sls_cStatus,sls_cRedLight,sls_cGreenLight,sls_cYellowLight,"+
                    "sls_cAlertRing,sls_iIntervalTime,sls_iDurationTime,sls_dUpdateTime"+
                     ") VALUES ("+
                     "@Id,@Status,@Red,@Green,@Yellow,@Alert,@Interval,@Duration,@Update"+
                     ")";
                List<SqlParameter> sqlparams = new List<SqlParameter>();
                sqlparams.Add(SQLHelper.MakeInParam("@Id", SqlDbType.UniqueIdentifier, 0, status.sls_cRecordID));
                sqlparams.Add(SQLHelper.MakeInParam("@Status", SqlDbType.NVarChar, 100, status.sls_cStatus));
                sqlparams.Add(SQLHelper.MakeInParam("@Red", SqlDbType.NVarChar, 10, status.sls_cRedLight));
                sqlparams.Add(SQLHelper.MakeInParam("@Green", SqlDbType.NVarChar, 10, status.sls_cGreenLight));
                sqlparams.Add(SQLHelper.MakeInParam("@Yellow", SqlDbType.NVarChar, 10, status.sls_cYellowLight));
                sqlparams.Add(SQLHelper.MakeInParam("@Alert", SqlDbType.NVarChar, 10, status.sls_cAlertRing));
                sqlparams.Add(SQLHelper.MakeInParam("@Interval", SqlDbType.Int, 0, status.sls_iIntervalTime));
                sqlparams.Add(SQLHelper.MakeInParam("@Duration", SqlDbType.Int, 0, status.sls_iDurationTime));
                sqlparams.Add(SQLHelper.MakeInParam("@Update", SqlDbType.DateTime, 0, DateTime.Now));
                int rowsAffected = SQLHelper.ExecuteNonQuery(strSQL, sqlparams.ToArray());

                if (rowsAffected > 0 && groupId != null && groupId!=Guid.Empty)
                {
                    strSQL = "INSERT INTO SignalStatusGroupItem_sgi(sgi_cGroupID,sgi_cRecordID) VALUES (@GroupId,@RecId)";
                    sqlparams = new List<SqlParameter>();
                    sqlparams.Add(SQLHelper.MakeInParam("@GroupId", SqlDbType.UniqueIdentifier, 0, groupId));
                    sqlparams.Add(SQLHelper.MakeInParam("@RecId", SqlDbType.UniqueIdentifier, 0, status.sls_cRecordID));
                    rowsAffected = SQLHelper.ExecuteNonQuery(strSQL, sqlparams.ToArray());
                }
                if (rowsAffected > 0)//当插入的行数小于等于0时,插入失败
                {
                    trans.Commit();
                    status.sls_dUpdateTime = DateTime.Now;
                    return true;
                }
                trans.Rollback();
                return false;
            }
            catch (Exception e)
            {
                if (trans != null) trans.Rollback();
                return false;
            }
            finally
            {
                if (trans != null) trans.Dispose();
                if (cmd != null) cmd.Dispose();
                if (cn.State == ConnectionState.Open) cn.Close();
                if (cn != null) cn.Dispose();
            }
        }
Esempio n. 16
0
 private bool DelSignalStatusData(SignalLightsStatus_sls_Info status)
 {
     if (_gpos < 0 || _gpos >= GroupInfos.Count) return false;
     ReturnValueInfo rv = ((SignalLightsStatusBL)this._signalLightsStatusBL).SaveGroupSignalStatus(status,GroupInfos[_gpos].ssg_cGroupID, Common.DefineConstantValue.EditStateEnum.OE_Delete);
     return rv.boolValue;
 }
Esempio n. 17
0
 private void InputStatus(SignalLightsStatus_sls_Info status)
 {
     if (status.sls_cRecordID == Guid.Empty) status.sls_cRecordID = Guid.NewGuid();
     //status.sls_cRecordID = new Guid(this.txtStatusRecID.Text);
     status.sls_cStatus = (cboStatusCode.SelectedItem != null) ? ((ComboBoxItem)cboStatusCode.SelectedItem).Value.ToString() : string.Empty;
     status.sls_cStatusName = (cboStatusCode.SelectedItem != null) ? ((ComboBoxItem)cboStatusCode.SelectedItem).Text : string.Empty;
     status.sls_cYellowLight = cboStatusYellowLight.SelectedItem.ToString();
     status.sls_cRedLight = cboStatusRedLight.SelectedItem.ToString();
     status.sls_cGreenLight = cboStatusGreenLight.SelectedItem.ToString();
     status.sls_cAlertRing = cboStatusAlertRing.SelectedItem.ToString();
     int x = 0;
     Int32.TryParse(txtStatusIntervalTime.Text, out x);
     status.sls_iIntervalTime = x;
     Int32.TryParse(txtStatusDurationTime.Text, out x);
     status.sls_iDurationTime = x;
 }
Esempio n. 18
0
            public UserInputData(SignalLightsStatus_sls_Info showInfo)
            {
                this.sls_cRecordID = showInfo.sls_cRecordID;

                this.sls_cStatus = showInfo.sls_cStatus;

                this.sls_cRedLight = getStatc(showInfo.sls_cRedLight);

                this.sls_cGreenLight = getStatc(showInfo.sls_cGreenLight);

                this.sls_cYellowLight = getStatc(showInfo.sls_cYellowLight);

                this.sls_cAlertRing = getStyle(showInfo.sls_cAlertRing);

                this.sls_iIntervalTime = showInfo.sls_iIntervalTime;

                this.sls_iDurationTime = showInfo.sls_iDurationTime;
            }
Esempio n. 19
0
 private void SetSignalStatusData(int srcPos)
 {
     SignalLightsStatus_sls_Info status = (srcPos >= 0 && srcPos < SignalStatusInfos.Count) ?
         SignalStatusInfos[srcPos] :
         (srcPos == SignalStatusInfos.Count ? (new SignalLightsStatus_sls_Info()) : null);
     if (status == null) return;
     SignalLightsStatus_sls_Info newstatus = new SignalLightsStatus_sls_Info();
     newstatus.Copy(status);
     InputStatus(newstatus);
     if (_gpos < 0 || _gpos >= GroupInfos.Count)
     {
         MessageBox.Show(this, "請選擇所在的信號狀態群組!", "錯誤提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (!CheckSignalStatusDataForSave(newstatus, GroupInfos[_gpos].ssg_cGroupID))
     {
         MessageBox.Show(this, "工程狀態已存在!", "錯誤提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (srcPos == SignalStatusInfos.Count)
     {
         if (!this.SaveSignalStatusData(newstatus, false))
         {
             MessageBox.Show(this, "添加信號狀態信息失敗!", "錯誤提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         SignalStatusInfos.Add(newstatus);
     }
     else
     {
         if (!this.SaveSignalStatusData(newstatus, true))
         {
             MessageBox.Show(this, "保存信號狀態信息失敗!", "錯誤提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         status.Copy(newstatus);
     }
     lvStatus.SetDataSource(_signalStatusInfos);
     ChangeSignalSelected(srcPos);
 }
Esempio n. 20
0
        private void SysToolBar_OnItemSave_Click(object sender, EventArgs e)
        {
            SignalLightsStatus_sls_Info objInfo = null;

            UserInputData tempUserData = proUserData.SelectedObject as UserInputData;

            objInfo = new SignalLightsStatus_sls_Info();

            objInfo.sls_cStatus = tempUserData.sls_cStatus;

            objInfo.sls_cGreenLight = tempUserData.sls_cGreenLight.ToString();

            objInfo.sls_cYellowLight = tempUserData.sls_cYellowLight.ToString();

            objInfo.sls_cRedLight = tempUserData.sls_cRedLight.ToString();

            objInfo.sls_cAlertRing = tempUserData.sls_cAlertRing.ToString();

            objInfo.sls_cRecordID = this._editInfo.sls_cRecordID;

            objInfo.sls_iDurationTime = tempUserData.sls_iDurationTime;

            objInfo.sls_iIntervalTime = tempUserData.sls_iIntervalTime;

            if (objInfo.sls_cStatus == string.Empty)
            {
                ShowInformationMessage("工程狀態不能為空。");
                return;
            }

            ReturnValueInfo returnInfo = null;

            try
            {
                if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Insert)
                {
                    returnInfo = this._signalLightsStatusBL.Save(objInfo, Common.DefineConstantValue.EditStateEnum.OE_Insert);
                }
                else if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Update)
                {
                    returnInfo = this._signalLightsStatusBL.Save(objInfo, Common.DefineConstantValue.EditStateEnum.OE_Update);
                }

                if (returnInfo.boolValue)
                {
                    ShowInformationMessage("操作成功!");

                    if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Insert)
                    {
                        proUserData.SelectedObject = new UserInputData();

                        this._editInfo.sls_cRecordID = Guid.NewGuid();
                    }
                    else
                    {

                        this.Close();
                    }
                    if (this.FromCloseCallBack != null)
                    {
                        FromCloseCallBack();
                    }
                }
                else
                {
                    ShowErrorMessage("保存失敗!");
                }
            }
            catch (Exception Ex)
            {

                ShowErrorMessage(Ex.Message); ;
            }
        }
Esempio n. 21
0
        public ReturnValueInfo Save(IModelObject itemEntity, Common.DefineConstantValue.EditStateEnum EditMode)
        {
            ReturnValueInfo returnInfo = new ReturnValueInfo(false);
            SignalLightsStatus_sls_Info newObj = itemEntity as SignalLightsStatus_sls_Info;
            SignalLightsStatus_sls_Info cond = new SignalLightsStatus_sls_Info();
            try
            {
                switch (EditMode)
                {
                    case Common.DefineConstantValue.EditStateEnum.OE_Insert:

                        cond.sls_cStatus = newObj.sls_cStatus;
                        var newExist = this._signalLightsStatusDA.SearchRecords(cond);
                        if (newExist.Count > 0)
                        {
                            throw new Exception("此工程狀態已經設置控制信號,不能重複設置。");
                        }
                        newObj.sls_cRecordID = Guid.NewGuid();
                        returnInfo.boolValue = this._signalLightsStatusDA.InsertRecord(newObj);

                        break;
                    case Common.DefineConstantValue.EditStateEnum.OE_Update:

                        cond.sls_cStatus = newObj.sls_cStatus;
                        var oldObjs = this._signalLightsStatusDA.SearchRecords(cond);
                        if (oldObjs.Count > 0)
                        {
                            throw new Exception("此工程狀態已經設置控制信號,不能重複設置。");
                        }

                        returnInfo.boolValue = this._signalLightsStatusDA.UpdateRecord(newObj);

                        break;
                    case Common.DefineConstantValue.EditStateEnum.OE_Delete:

                        returnInfo.boolValue = this._signalLightsStatusDA.DeleteRecord(itemEntity as SignalLightsStatus_sls_Info);

                        break;
                    case Common.DefineConstantValue.EditStateEnum.OE_ReaOnly:
                        break;
                    default:
                        break;
                }
            }
            catch (Exception Ex)
            {

                throw Ex;
            }

            return returnInfo;
        }
Esempio n. 22
0
        public bool DeleteGroupSignalStatus(SignalLightsStatus_sls_Info status)
        {
            if (status.sls_cRecordID == null || status.sls_cRecordID == Guid.Empty)
            {
                return false;
            }
            SqlConnection cn = null;
            SqlCommand cmd = null;
            SqlTransaction trans = null;
            try
            {
                cn = new SqlConnection(SQLHelper.ConnectionString);
                if (cn.State == ConnectionState.Closed) cn.Open();
                trans = cn.BeginTransaction();

                string strSQL = "DELETE FROM SignalStatusGroupItem_sgi WHERE sgi_cRecordID=@RecId";
                List<SqlParameter> sqlparams = new List<SqlParameter>();
                sqlparams.Add(SQLHelper.MakeInParam("@RecId", SqlDbType.UniqueIdentifier, 0, status.sls_cRecordID));
                int rowsAffected = SQLHelper.ExecuteNonQuery(strSQL, sqlparams.ToArray());

                if (rowsAffected >= 0)
                {
                    strSQL = "DELETE FROM dbo.SignalLightsStatus_sls WHERE sls_cRecordID=@Id";
                    sqlparams = new List<SqlParameter>();
                    sqlparams.Add(SQLHelper.MakeInParam("@Id", SqlDbType.UniqueIdentifier, 0, status.sls_cRecordID));
                    rowsAffected = SQLHelper.ExecuteNonQuery(strSQL, sqlparams.ToArray());
                }
                if (rowsAffected > 0)//当删除的行数小于等于0时,插入失败
                {
                    trans.Commit();
                    return true;
                }
                trans.Rollback();
                return false;
            }
            catch (Exception e)
            {
                if (trans != null) trans.Rollback();
                return false;
            }
            finally
            {
                if (trans != null) trans.Dispose();
                if (cmd != null) cmd.Dispose();
                if (cn.State == ConnectionState.Open) cn.Close();
                if (cn != null) cn.Dispose();
            }
        }