Beispiel #1
0
        public static string GetId_Name(string _pName)
        {
            Databases obj = CDatabases.PropertiesData(SearchName(_pName));

            if (obj != null)
            {
                return(obj.Databases_id);
            }
            return("");
        }
Beispiel #2
0
        public static string GetName_Id(string _pId)
        {
            Databases obj = CDatabases.PropertiesData(PKId(_pId));

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

            switch (fAction)
            {
            case ListOption.active:

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

                break;

            case ListOption.notactive:

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

                break;

            case ListOption.Search:
                if (txt_databases_name.Text != "")
                {
                    LoadData(CDatabases.TblData(CDatabases_exten.SearchName(txt_databases_name.Text)));
                }
                else
                {
                    LoadData(CDatabases.TblData(CDatabases_exten.Active()));
                }
                break;

            default:
                LoadData(CDatabases.TblData(CDatabases_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           = CDatabases.PropertiesData(CDatabases_exten.PKId(pPkValue));
                this.EnableControls(false);
                break;

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

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

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

            case BtnEvent.Print:
                btn_save.Text = "PRINT";
                obj           = CDatabases.PropertiesData(CDatabases_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 SQLITE_DAL();
                        dalsession.BeginTransaction();
                        CDatabases.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 SQLITE_DAL();
                        dalsession.BeginTransaction();
                        CDatabases.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 SQLITE_DAL();
                        dalsession.BeginTransaction();
                        CDatabases.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;
                }
            }
        }