Beispiel #1
0
        public static string GetName_Id(string _pId)
        {
            User obj = CUser.PropertiesData(PKId(_pId));

            if (obj != null)
            {
                return(obj.User_name);
            }
            return("");
        }
Beispiel #2
0
        public static string GetId_Name(string _pName)
        {
            User obj = CUser.PropertiesData(SearchName(_pName));

            if (obj != null)
            {
                return(obj.User_id);
            }
            return("");
        }
Beispiel #3
0
        public void List_Option(ListOption pAction)
        {
            fAction = pAction;

            switch (fAction)
            {
            case ListOption.active:

                if (chk_notactive.Checked == true)
                {
                    LoadData(CUser.TblData(CUser_exten.NotActive()));
                }
                else
                {
                    LoadData(CUser.TblData(CUser_exten.Active()));
                }

                break;

            case ListOption.notactive:

                if (chk_notactive.Checked == true)
                {
                    LoadData(CUser.TblData(CUser_exten.NotActive()));
                }
                else
                {
                    LoadData(CUser.TblData(CUser_exten.Active()));
                }

                break;

            case ListOption.Search:
                if (txt_user_name.Text != "")
                {
                    LoadData(CUser.TblData(CUser_exten.SearchName(txt_user_name.Text)));
                }
                else
                {
                    LoadData(CUser.TblData(CUser_exten.Active()));
                }
                break;

            default:
                LoadData(CUser.TblData(CUser_exten.Active()));
                break;
            }
        }
Beispiel #4
0
        public void SetAction(BtnEvent pAction, string pPkValue)
        {
            fAction = pAction;

            switch (fAction)
            {
            case BtnEvent.Open:
                btn_save.Text = "CLOSE";
                obj           = CUser.PropertiesData(CUser_exten.PKId(pPkValue));
                this.EnableControls(false);
                break;

            case BtnEvent.New:
                btn_save.Text = "SAVE";
                obj           = new User();
                this.EnableControls(true);
                break;

            case BtnEvent.Edit:
                btn_save.Text = "UPDATE";
                obj           = CUser.PropertiesData(CUser_exten.PKId(pPkValue));
                this.EnableControls(true);
                break;

            case BtnEvent.Delete:
                btn_save.Text = "CONFIRM\r\nDELETE";
                obj           = CUser.PropertiesData(CUser_exten.PKId(pPkValue));
                this.EnableControls(false);
                break;

            case BtnEvent.Print:
                btn_save.Text = "PRINT";
                obj           = CUser.PropertiesData(CUser_exten.PKId(pPkValue));
                this.EnableControls(false);
                break;
            }

            this.LoadData();
        }
Beispiel #5
0
        private void Save_Event()
        {
            if (Validation() != false)
            {
                switch (fAction)
                {
                case BtnEvent.Open:
                    this.Hide();
                    Form_NeedToRefresh();
                    break;

                case BtnEvent.New:
                    try
                    {
                        var vData = FetchData();

                        dalsession = new DAL();
                        dalsession.BeginTransaction();
                        CUser.Insert(vData, dalsession);
                        dalsession.Commit();

                        MessageBox.Show(this.FindForm(), "Record Saved Successfully.", "Save...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Hide();
                        Form_NeedToRefresh();
                    }
                    catch (Exception ex)
                    {
                        if (dalsession != null)
                        {
                            dalsession.Rollback();
                        }
                        MessageBox.Show(this.FindForm(), "Something Goes Wrong \r\n" + ex.Message, "Could Not Save...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SetFocus();
                        return;
                    }
                    break;

                case BtnEvent.Edit:
                    try
                    {
                        var vData = FetchData();

                        dalsession = new DAL();
                        dalsession.BeginTransaction();
                        CUser.Update(vData, dalsession);
                        dalsession.Commit();

                        MessageBox.Show(this.FindForm(), "Record Updated Successfully.", "Update...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Hide();
                        Form_NeedToRefresh();
                    }
                    catch (Exception ex)
                    {
                        if (dalsession != null)
                        {
                            dalsession.Rollback();
                        }
                        MessageBox.Show(this.FindForm(), "Something Goes Wrong \r\n" + ex.Message, "Could Not Update...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SetFocus();
                        return;
                    }
                    break;

                case BtnEvent.Delete:
                    try
                    {
                        dalsession = new DAL();
                        dalsession.BeginTransaction();
                        CUser.Delete(vId, dalsession);
                        dalsession.Commit();

                        MessageBox.Show(this.FindForm(), "Record Deleted Successfully.", "Delete...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Hide();
                        Form_NeedToRefresh();
                    }
                    catch (Exception ex)
                    {
                        if (dalsession != null)
                        {
                            dalsession.Rollback();
                        }
                        MessageBox.Show(this.FindForm(), "Something Goes Wrong \r\n" + ex.Message, "Could Not Update...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SetFocus();
                        return;
                    }
                    break;

                case BtnEvent.Print:
                    this.Hide();
                    Form_NeedToRefresh();
                    break;
                }
            }
        }