コード例 #1
0
        public void Delete()
        {
            if (txtLoginName.Text == "" || txtPassword.Text == "")
            {
                return;
            }

            if (dtLoginInfo.Rows[0][AdminRight] != DBNull.Value && Convert.ToBoolean(dtLoginInfo.Rows[0][AdminRight]) == true)
            {
                Methods.ShowMessage("CANNOT_DELETE_ADMIN", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (Methods.ShowMessage("3", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            try
            {
                DBEngine.beginTransaction();
                DBEngine.exec("SC_User_Delete", CommonConst.A_LoginID, StaticVars.LoginID, "@p_LoginID", dtLoginInfo.Rows[0][strLoginID]);
                DBEngine.commit();
                Methods.ShowMessage(Common.CommonConst.DELETE_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                DBEngine.rollback();
                Methods.ShowError(ex);
            }
        }
コード例 #2
0
        // =======================================================
        // NAME:	Commit
        // TASK:	Override Commit() method to save data
        // PARAM:
        // RETURN:	TRUE = successfully, FALSE = fail
        // THROW:
        // REV:
        //	2003-12-
        // =======================================================
        /// <summary>
        /// Save data
        /// </summary>
        public override bool Commit()
        {
            // remember current Action State
            HPA.Component.Framework.Base.EActionState eOldActionState = ActionState;

            try
            {
                // switch to COMMITING state
                ActionState = HPA.Component.Framework.Base.EActionState.BUSY;

                // wait-cursor
                this.Cursor = Cursors.WaitCursor;

                try
                {
                    DBEngine.beginTransaction();

                    // TODO - add code here to perform commiting tasks

                    DBEngine.commit();
                }
                catch (Exception ex)
                {
                    DBEngine.rollback();
                    throw(ex);
                }

                // restore cursor
                this.Cursor = Cursors.Default;

                // restore action state
                ActionState = eOldActionState;
            }
            catch (Exception e)
            {
                // restore cursor
                this.Cursor = Cursors.Default;

                // show error
                HPA.Common.Helper.ShowException(e, this.Name + ".Commit()", null);

                // restore action state
                ActionState = eOldActionState;

                // unable to commit
                return(false);
            }

            // commit successfully
            return(true);
        }
コード例 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            HPA.Properties.Settings.Default.LanguageID          = txtLanguageID.Text;
            HPA.Properties.Settings.Default.EnterToTab          = ckbEnter_to_tab.Checked;
            HPA.Properties.Settings.Default.UsedModenMenu       = ckbUsedModenMenu.Checked;
            HPA.Properties.Settings.Default.WallpaperPath       = strWallPaperPath;
            HPA.Properties.Settings.Default.LoginWallpaper      = strLoginWallpaper;
            HPA.Properties.Settings.Default.LockProgramInterval = Convert.ToInt32(txtInterval.EditValue);
            HPA.Properties.Settings.Default.Save();
            if (dtLableNameList == null)
            {
                return;
            }
            try
            {
                DataTable dtChanged = dtLableNameList.GetChanges();
                if (dtChanged == null || dtChanged.Rows.Count <= 0)
                {
                    return;
                }
                DBEngine.beginTransaction();
                foreach (DataRow dr in dtChanged.Rows)
                {
                    DBEngine.exec("sp_LableName_Language_Save", CommonConst.A_LoginID, UIMessage.userID,
                                  "@LanguageID", txtLanguageID.Text, "@MessageID", dr["MessageID"], "@Content", dr["Content"]);
                }
                DBEngine.commit();
                dtLableNameList.AcceptChanges();
                UIMessage.ShowMessage(CommonConst.DATASAVED_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                // m_dtTableData.RejectChanges();
                DBEngine.rollback();
                throw (ex);
            }

            // restore cursor
            this.Cursor = Cursors.Default;
        }
コード例 #4
0
 public void Add()
 {
     if (txtLoginName.Text != "" && txtPassword.Text != "")
     {
         try
         {
             DBEngine.beginTransaction();
             DBEngine.exec("SC_User_Insert", "@p_LoginName", txtLoginName.Text.Trim(),
                           "@p_Password", txtPassword.Text.Trim(),
                           "@p_EmployeeID", txtEmployeeID.Text.Trim(),
                           "@p_DepartmentID", dtLoginInfo.Rows[0]["DepartmentID"]);
             DBEngine.commit();
             LoadLoginInfo();
         }
         catch (Exception ex)
         {
             DBEngine.rollback();
             Methods.ShowError(ex);
             return;
         }
     }
 }
コード例 #5
0
        public override bool OnDelete()
        {
            if (!base.OnDelete())
            {
                return(false);
            }
            if (dtLoginInfor.Rows[0][AdminRight] != DBNull.Value && Convert.ToBoolean(dtLoginInfor.Rows[0][AdminRight]) == true)
            {
                UIMessage.ShowMessage("CANNOT_DELETE_ADMIN", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            if (UIMessage.ShowMessage(3, System.Windows.Forms.MessageBoxButtons.YesNo,
                                      System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
            {
                return(false);
            }
            try
            {
                DBEngine.beginTransaction();
                // Delete user from tblSC_Login
                // Delete from Right table
                // Delete from DevSecView table
                DBEngine.exec("SC_User_Delete",
                              CommonConst.A_LoginID, UserID,
                              "@p_LoginID", dtLoginInfor.Rows[0][LoginID]);
            }
            catch (Exception ex)
            {
                DBEngine.rollback();
                HPA.Common.Helper.ShowException(ex, this.Name, "OnDelete");
            }
            UIMessage.ShowMessage(HPA.Common.CommonConst.DELETE_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information);
            LoadLoginInfo();
            txtEmployeeID.Focus();
            DBEngine.commit();
            return(true);
        }
コード例 #6
0
        public override bool Commit()
        {
            try
            {
                if (SaveProdureName_TA.Equals(string.Empty))
                {
                    return(true);
                }
                if (UIMessage.ShowMessage(2, System.Windows.Forms.MessageBoxButtons.YesNo,
                                          System.Windows.Forms.MessageBoxIcon.Question) == DialogResult.No)
                {
                    return(false);
                }
                // wait-cursor
                this.Cursor = Cursors.WaitCursor;
                short a;
                try
                {
                    DBEngine.beginTransaction();
                    CRowUtility.updateDataRow(grvAttendanceList);
                    grvAttendanceList.BeginUpdate();
                    if (dtAttendanceList != null)
                    {
                        DataTable dtChanges = dtAttendanceList.GetChanges();
                        foreach (DataRow dr in dtChanges.Rows)
                        {
                            foreach (DataColumn dc in dtChanges.Columns)
                            {
                                if (dr[dc.ColumnName] != dr[dc.ColumnName, DataRowVersion.Original])
                                {
                                    if (Int16.TryParse(dc.ColumnName, out a))
                                    {
                                        DBEngine.exec(SaveProdureName_TA,
                                                      CommonConst.A_LoginID, this.UserID,
                                                      CommonConst.A_Month, month,
                                                      CommonConst.A_Year, year,
                                                      CommonConst.A_EmployeeID, dr[CommonConst.EmployeeID],
                                                      "@DateName", dc.ColumnName,
                                                      "@Value", dr[dc.ColumnName]);
                                    }
                                }
                            }
                        }
                    }
                    grvAttendanceList.EndUpdate();
                    dtAttendanceList.AcceptChanges();
                    DBEngine.commit();
                }
                catch (Exception ex)
                {
                    grvAttendanceList.EndUpdate();
                    DBEngine.rollback();
                    throw (ex);
                }

                // restore cursor
                this.Cursor = Cursors.Default;
            }
            catch (Exception e)
            {
                // restore cursor
                this.Cursor = Cursors.Default;

                // show error
                HPA.Common.Helper.ShowException(e, this.Name + ".Commit()", null);
                // unable to commit
                return(false);
            }
            txtEmployeeID_Search.Focus();
            txtEmployeeID_Search.SelectAll();
            return(true);
        }
コード例 #7
0
        public void Save()
        {
            bool success = false;

            if (txtLoginName.Text == "" || txtPassword.Text == "")
            {
                return;
            }
            try
            {
                DBEngine.beginTransaction();
                //if (dtLoginInfo.GetChanges() != null && dtLoginInfo.GetChanges().Rows.Count > 0)
                {
                    DBEngine.exec("SC_LoginInfo_Save", CommonConst.A_LoginID, StaticVars.LoginID,
                                  "@LoginName", txtLoginName.Text,
                                  "@Password", Encryption.EncryptText(txtPassword.Text, true),
                                  "@EmployeeID", txtEmployeeID.Text,
                                  "@DepartmentID", dtLoginInfo.Rows[0][strDepartmentID].ToString());
                }
                if (dtObjectList.GetChanges() != null && dtObjectList.GetChanges().Rows.Count > 0)
                {
                    foreach (DataRow dtRow in dtObjectList.Rows)
                    {
                        DBEngine.exec("SC_UserObjects_Save",
                                      CommonConst.A_LoginID, StaticVars.LoginID,
                                      "@p_LoginID", dtLoginInfo.Rows[0][strLoginID],
                                      "@p_ObjectID", dtRow[strObjectID],
                                      "@p_FullAccess", dtRow["Right"]);
                    }
                }
                if (dtDepartment.GetChanges() != null && dtDepartment.GetChanges().Rows.Count > 0)
                {
                    foreach (DataRow dtRow in dtDepartment.Rows)
                    {
                        DBEngine.exec("SC_UserDeptViewInfo_Save",
                                      CommonConst.A_LoginID, StaticVars.LoginID,
                                      "@p_LoginID", dtLoginInfo.Rows[0][strLoginID],
                                      "@p_DepartmentID", dtRow[strDepartmentID],
                                      "@p_ViewInfo", dtRow[strViewInfo]);
                    }
                }
                if (dtSection.GetChanges() != null && dtSection.GetChanges().Rows.Count > 0)
                {
                    foreach (DataRow dtRow in dtSection.Rows)
                    {
                        DBEngine.exec("SC_UserSectViewInfo_Save",
                                      CommonConst.A_LoginID, StaticVars.LoginID,
                                      "@p_LoginID", dtLoginInfo.Rows[0][strLoginID],
                                      "@p_DepartmentID", dtRow[strDepartmentID],
                                      "@p_SectionID", dtRow[strSectionID],
                                      "@p_ViewInfo", dtRow[strViewInfo]);
                    }
                }
                DBEngine.commit();
                LoadLoginInfo();
                success = true;
            }
            catch
            {
                DBEngine.rollback();
                success = false;
            }

            if (success)
            {
                Methods.ShowMessage(Common.CommonConst.DATASAVED_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                Methods.ShowMessage(Common.CommonConst.DELETE_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #8
0
        // =======================================================
        // NAME:	OnDelete
        // TASK:	Override OnDelete() method to perform delete tasks.
        // PARAM:
        // RETURN:	TRUE = successfully, FALSE = fail
        // THROW:
        // REV:
        //	2003-12-
        // =======================================================
        /// <summary>
        /// Perform delete tasks
        /// </summary>
        public override bool OnDelete()
        {
            if (!base.OnDelete())
            {
                return(false);
            }


            try
            {
                // wait-cursor
                this.Cursor = Cursors.WaitCursor;

                DataRow dr = grvShiftSetting.GetDataRow(grvShiftSetting.FocusedRowHandle);
                if (dr == null)
                {
                    UIMessage.ShowMessage(1992, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                    return(false);
                }

                grvShiftSetting.CloseEditor();
                grvShiftSetting.UpdateCurrentRow();
                grvShiftSetting.BeginUpdate();

                if (UIMessage.ShowMessage(3, System.Windows.Forms.MessageBoxButtons.YesNo,
                                          System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    DBEngine.beginTransaction();
                    try
                    {
                        DBEngine.exec("MD_WorkingShift_Delete",
                                      "@ShiftCode", dr[ShiftCode, DataRowVersion.Original],
                                      CommonConst.A_LoginID, this.UserID);
                    }
                    catch (Exception ex)
                    {
                        DBEngine.rollback();
                        HPA.Common.Helper.ShowException(ex, this.Name, "OnDelete");
                    }
                    DBEngine.commit();
                    UIMessage.ShowMessage(CommonConst.DELETE_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    myInit();
                }

                grvShiftSetting.EndUpdate();

                // TODO - add code here to perform delete tasks


                // restore cursor
                this.Cursor = Cursors.Default;
            }
            catch (Exception e)
            {
                // restore cursor
                this.Cursor = Cursors.Default;

                // show error
                HPA.Common.Helper.ShowException(e, this.Name + ".OnDelete()", null);


                // unable to delete
                return(false);
            }

            // delete successfully
            return(true);
        }
コード例 #9
0
        // =======================================================
        // NAME:	Commit
        // TASK:	Override Commit() method to save data
        // PARAM:
        // RETURN:	TRUE = successfully, FALSE = fail
        // THROW:
        // REV:
        //	2003-12-
        // =======================================================
        /// <summary>
        /// Save data
        /// </summary>
        public override bool Commit()
        {
            try
            {
                // wait-cursor
                this.Cursor = Cursors.WaitCursor;

                try
                {
                    DBEngine.beginTransaction();
                    DBEngine.exec("MD_WorkingShift_Update",
                                  "@ShiftCode", txtShiftCode.Text,
                                  "@ShiftName", txtShiftName.Text,
                                  "@ShiftAllowance", txtShiftAllowance.EditValue,
                                  "@HilightColorCode", txtHilightColorCode.EditValue,
                                  "@WorkStart1", tedWorkStart1.EditValue,
                                  "@WorkEnd1", tedWorkEnd1.EditValue,
                                  "@BreakStart1", tedBreakStart1.EditValue,
                                  "@BreakEnd1", tedBreakEnd1.EditValue,
                                  "@DayOff1", ckbDayoff1.EditValue,
                                  "@WorkStart2", tedWorkStart2.EditValue,
                                  "@WorkEnd2", tedWorkEnd2.EditValue,
                                  "@BreakStart2", tedBreakStart2.EditValue,
                                  "@BreakEnd2", tedBreakEnd2.EditValue,
                                  "@DayOff2", ckbDayoff2.EditValue,
                                  "@WorkStart3", tedWorkStart3.EditValue,
                                  "@WorkEnd3", tedWorkEnd3.EditValue,
                                  "@BreakStart3", tedBreakStart3.EditValue,
                                  "@BreakEnd3", tedBreakEnd3.EditValue,
                                  "@DayOff3", ckbDayoff3.EditValue,
                                  "@WorkStart4", tedWorkStart4.EditValue,
                                  "@WorkEnd4", tedWorkEnd4.EditValue,
                                  "@BreakStart4", tedBreakStart4.EditValue,
                                  "@BreakEnd4", tedBreakEnd4.EditValue,
                                  "@DayOff4", ckbDayoff4.EditValue,
                                  "@WorkStart5", tedWorkStart5.EditValue,
                                  "@WorkEnd5", tedWorkEnd5.EditValue,
                                  "@BreakStart5", tedBreakStart5.EditValue,
                                  "@BreakEnd5", tedBreakEnd5.EditValue,
                                  "@DayOff5", ckbDayoff5.EditValue,
                                  "@WorkStart6", tedWorkStart6.EditValue,
                                  "@WorkEnd6", tedWorkEnd6.EditValue,
                                  "@BreakStart6", tedBreakStart6.EditValue,
                                  "@BreakEnd6", tedBreakEnd6.EditValue,
                                  "@DayOff6", ckbDayoff6.EditValue,
                                  "@WorkStart7", tedWorkStart7.EditValue,
                                  "@WorkEnd7", tedWorkEnd7.EditValue,
                                  "@BreakStart7", tedBreakStart7.EditValue,
                                  "@BreakEnd7", tedBreakEnd7.EditValue,

                                  "@OTBeforeStart1", tedOTBeforeStart1.EditValue,
                                  "@OTBeforeStart2", tedOTBeforeStart2.EditValue,
                                  "@OTBeforeStart3", tedOTBeforeStart3.EditValue,
                                  "@OTBeforeStart4", tedOTBeforeStart4.EditValue,
                                  "@OTBeforeStart5", tedOTBeforeStart5.EditValue,
                                  "@OTBeforeStart6", tedOTBeforeStart6.EditValue,
                                  "@OTBeforeStart7", tedOTBeforeStart7.EditValue,

                                  "@OTBeforeEnd1", tedOTBeforeEnd1.EditValue,
                                  "@OTBeforeEnd2", tedOTBeforeEnd2.EditValue,
                                  "@OTBeforeEnd3", tedOTBeforeEnd3.EditValue,
                                  "@OTBeforeEnd4", tedOTBeforeEnd4.EditValue,
                                  "@OTBeforeEnd5", tedOTBeforeEnd5.EditValue,
                                  "@OTBeforeEnd6", tedOTBeforeEnd6.EditValue,
                                  "@OTBeforeEnd7", tedOTBeforeEnd7.EditValue,

                                  "@OTAfterStart1", tedOTAfterStart1.EditValue,
                                  "@OTAfterStart2", tedOTAfterStart2.EditValue,
                                  "@OTAfterStart3", tedOTAfterStart3.EditValue,
                                  "@OTAfterStart4", tedOTAfterStart4.EditValue,
                                  "@OTAfterStart5", tedOTAfterStart5.EditValue,
                                  "@OTAfterStart6", tedOTAfterStart6.EditValue,
                                  "@OTAfterStart7", tedOTAfterStart7.EditValue,

                                  "@OTAfterEnd1", tedOTAfterEnd1.EditValue,
                                  "@OTAfterEnd2", tedOTAfterEnd2.EditValue,
                                  "@OTAfterEnd3", tedOTAfterEnd3.EditValue,
                                  "@OTAfterEnd4", tedOTAfterEnd4.EditValue,
                                  "@OTAfterEnd5", tedOTAfterEnd5.EditValue,
                                  "@OTAfterEnd6", tedOTAfterEnd6.EditValue,
                                  "@OTAfterEnd7", tedOTAfterEnd7.EditValue,

                                  "@DayOff7", ckbDayoff7.EditValue,
                                  CommonConst.A_LoginID, this.UserID);



                    DBEngine.commit();
                }
                catch (Exception ex)
                {
                    DBEngine.rollback();
                    throw (ex);
                }
                m_dtShiftSetting.AcceptChanges();
                // restore cursor
                this.Cursor = Cursors.Default;
            }
            catch (Exception e)
            {
                // restore cursor
                this.Cursor = Cursors.Default;

                // show error
                HPA.Common.Helper.ShowException(e, this.Name + ".Commit()", null);


                // unable to commit
                return(false);
            }

            UIMessage.ShowMessage(CommonConst.DATASAVED_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.DirtyData = false;
            // commit successfully
            return(true);
        }
コード例 #10
0
        public override bool Commit()
        {
            const int pCheck = 0;

            try
            {
                // switch to COMMITING state
                this.Cursor = Cursors.WaitCursor;

                try
                {
                    DBEngine.beginTransaction();
                    if (dtLoginInfor.GetChanges() != null && dtLoginInfor.GetChanges().Rows.Count > 0)
                    {
                        if (!dtLoginInfor.Rows[0]["Password", DataRowVersion.Original].ToString().Equals(txtPassword.Text))
                        {
                            DBEngine.exec("SC_LoginInfo_Save",
                                          CommonConst.A_LoginID, UserID,
                                          "@LoginName", txtLoginName.Text,
                                          "@Password", Encryption.EncryptText(txtPassword.Text, true),
                                          "@EmployeeID", txtEmployeeID.Text,
                                          "@DepartmentID", txtDepartmentID.EditValue);
                        }
                    }

                    if (dtObjectList.GetChanges() != null && dtObjectList.GetChanges().Rows.Count > 0)
                    {
                        foreach (DataRow drObject in dtObjectList.GetChanges().Rows)
                        {
                            DBEngine.exec("SC_UserObjects_Save",
                                          CommonConst.A_LoginID, UserID,
                                          "@p_LoginID", dtLoginInfor.Rows[0][LoginID],
                                          "@p_ObjectID", drObject[ObjectID_D],
                                          "@p_FullAccess", drObject[Right_D]);
                        }
                    }
                    if (dtSectionList.GetChanges() != null && dtSectionList.GetChanges().Rows.Count > 0)
                    {
                        foreach (DataRow drSec in dtSectionList.GetChanges().Rows)
                        {
                            DBEngine.exec("SC_UserSectViewInfo_Save",
                                          CommonConst.A_LoginID, UserID,
                                          "@p_LoginID", dtLoginInfor.Rows[0][LoginID],
                                          "@p_DepartmentID", drSec[DepartmentID],
                                          "@p_SectionID", drSec[SectionID],
                                          "@p_ViewInfo", drSec[ViewInfo]);
                        }
                    }
                    if (dtDepartmentList.GetChanges() != null && dtDepartmentList.GetChanges().Rows.Count > 0)
                    {
                        foreach (DataRow drDept in dtDepartmentList.GetChanges().Rows)
                        {
                            DBEngine.exec("SC_UserDeptViewInfo_Save",
                                          CommonConst.A_LoginID, UserID,
                                          "@p_LoginID", dtLoginInfor.Rows[0][LoginID],
                                          "@p_DepartmentID", drDept[DepartmentID],
                                          "@p_ViewInfo", drDept[ViewInfo]);
                        }
                    }
                    DBEngine.commit();
                }
                catch (Exception ex)
                {
                    // dtEmployeeInformation.RejectChanges();
                    DBEngine.rollback();
                    throw (ex);
                }

                // restore cursor
                this.Cursor = Cursors.Default;
            }
            catch (Exception e)
            {
                // restore cursor
                this.Cursor = Cursors.Default;

                // show error
                HPA.Common.Helper.ShowException(e, this.Name + ".Commit()", null);

                return(false);
            }
            if (pCheck == 0 || pCheck == 1)
            {
                UIMessage.ShowMessage(HPA.Common.CommonConst.DATASAVED_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                UIMessage.ShowMessage(HPA.Common.CommonConst.DELETE_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            this.DirtyData = false;
            LoadLoginInfo();
            // commit successfully
            return(true);
        }