Exemple #1
0
 private static void InsertData(Article obj)
 {
     if (CheckData(obj) == false)
     {
         CArticle.Insert(obj, new DAL());
     }
     ;
 }
Exemple #2
0
        private static bool CheckData(Article obj)
        {
            string q = "USE CODEXSUN_DB; ";

            q += "SELECT * FROM " + ARTICLE.ARTICLE_TBL + " WHERE " + ARTICLE.ARTICLE_NO + " = '" + obj.Article_no + "'; ";

            using (IDataReader redr = new DAL().Listreader(q))
            {
                while (redr.Read() == true)
                {
                    obj.Article_id = redr[ARTICLE.ARTICLE_ID].ToString();

                    CArticle.Update(obj, new DAL());

                    return(true);
                }
                return(false);
            }
        }
Exemple #3
0
        private void Save_Event()
        {
            if (Validation() != false)
            {
                switch (fAction)
                {
                case BtnEvent.Open:
                    this.Hide();
                    Form_NeedToRefresh();
                    break;

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

                        dalsession = new DAL();
                        dalsession.BeginTransaction();
                        CArticle.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 = CollectData();

                        dalsession = new DAL();
                        dalsession.BeginTransaction();
                        CArticle.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();
                        CArticle.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;
                }
            }
        }