示例#1
0
 public void frmDeveloperEntry_Helper(int id)
 {
     InitializeComponent();
     InitializeForm();
     // access control id
     ModuleID = "ACC-01013";
     // retrieve data
     daCompanies1.Connection      = AppHelper.GetDbConnection();
     daCompanies1.ClearBeforeFill = true;
     try
     {
         if (id < 0)
         {
             this.BindingContext[this.dsCore1, "Companies"].AddNew();
             DataRowView dr = (DataRowView)this.BindingContext[this.dsCore1, "Companies"].Current;
             txMode = DataEntryModes.Add;
             // default field value
             dr["Active"] = 1;
             dr["Type"]   = "D";
         }
         else
         {
             daCompanies1.FillByID(this.dsCore1.Companies, id);
             txMode = DataEntryModes.Edit;
         }
     }
     catch (Exception ex)
     {
         // textfile logging
         Logger.ErrorRoutine(ex);
         // screen logging
         RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message,
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
 private void frmWarehouseEntry_Helper(int id)
 {
     // required by form designer
     InitializeComponent();
     // access control id
     ModuleID = "ACC-01013";
     // retrieve data
     daWarehouses1.Connection      = AppHelper.GetDbConnection();
     daWarehouses1.ClearBeforeFill = true;
     try
     {
         if (id < 0)
         {
             this.BindingContext[this.dsCore1, "Warehouses"].AddNew();
             DataRowView dr = (DataRowView)this.BindingContext[this.dsCore1, "Warehouses"].Current;
             dr["code"]   = DbHelper.GenerateNewWarehouseID();
             dr["Active"] = 1;
             txMode       = DataEntryModes.Add;
         }
         else
         {
             daWarehouses1.FillByID(this.dsCore1.Warehouses, id);
             txMode = DataEntryModes.Edit;
         }
     }
     catch (Exception ex)
     {
         // textfile logging
         Logger.ErrorRoutine(ex);
         // screen logging
         RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message,
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
示例#3
0
 private void c1Combo2_SelectedValueChanged(object sender, EventArgs e)
 {
     if (txMode == DataEntryModes.Add)
     {
         try
         {
             // get data
             dsCore                   ds = new dsCore();
             OrdersTableAdapter       od = new OrdersTableAdapter();
             OrderDetailsTableAdapter ta = new OrderDetailsTableAdapter();
             ds.EnforceConstraints = false;
             od.Connection         = AppHelper.GetDbConnection();
             od.FillByID(ds.Orders, (int)c1Combo2.SelectedValue);
             ta.Connection = AppHelper.GetDbConnection();
             ta.FillNotCompleted(ds.OrderDetails, (int)c1Combo2.SelectedValue);
             // clear grid
             dsCore1.OrderDetails.Clear();
             // fill grid with new data
             _grid.Redraw = false;
             DataRowView dv = (DataRowView)this.BindingContext[dsCore1, "Orders"].Current;
             dv["CompanyID"]  = ds.Orders[0].CompanyID;
             dv["CurrencyID"] = ds.Orders[0].CurrencyID;
             if (!ds.Orders[0].IsCompanyIDNull())
             {
                 c1Combo1.SelectedValue = ds.Orders[0].CompanyID;
             }
             if (!ds.Orders[0].IsCurrencyIDNull())
             {
                 c1Combo3.SelectedValue = ds.Orders[0].CurrencyID;
             }
             foreach (dsCore.OrderDetailsRow src in ds.OrderDetails.Rows)
             {
                 dsCore.OrderDetailsRow row = dsCore1.OrderDetails.NewOrderDetailsRow();
                 row.OrderID     = (int)dv["ID"];
                 row.ItemID      = src.ItemID;
                 row.ItemCode    = src.ItemCode;
                 row.ItemName    = src.ItemName;
                 row.Quantity    = src.Quantity;
                 row.UnitPrice   = src.UnitPrice;
                 row.TaxPct      = src.TaxPct;
                 row.Remarks     = src.Remarks;
                 row.MeasureCode = src.MeasureCode;
                 dsCore1.OrderDetails.AddOrderDetailsRow(row);
             }
             // redraw grid
             _grid.Redraw = true;
             _grid.Refresh();
             // recalculate order value
             c1Label1.Value = CountDetails();
         }
         catch (Exception ex)
         {
             // textfile logging
             Logger.ErrorRoutine(ex);
             // screen logging
             RibbonMessageBox.Show("ERROR Retrieving Detail Data: \n" + ex.Message,
                                   Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
 }
示例#4
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            this.Cursor = Cursors.AppStarting;

            // verify password
            if (c1TextBox2.Text != c1TextBox3.Text)
            {
                RibbonMessageBox.Show("Confirm Password not equal, please retype your password.",
                                      Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                c1TextBox2.Focus();
                return;
            }

            // store user data to database
            try
            {
                this.BindingContext[this.dsSecurity1, "Users"].EndCurrentEdit();
                DataRowView dr = (DataRowView)this.BindingContext[this.dsSecurity1, "Users"].Current;
                dr["Password"] = SecurityHelper.EncryptText(c1TextBox2.Text, c1TextBox1.Text);
                dr["Active"]   = 1;
                // update user
                daUsers.Update(this.dsSecurity1);
                // inform user
                RibbonMessageBox.Show("Data SUCCESSFULLY saved to database",
                                      Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                RibbonMessageBox.Show("ERROR while saving data to database: " + ex.Message,
                                      Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            this.dsSecurity1.AcceptChanges();
            this.Cursor = Cursors.Default;
            this.Close();
        }
示例#5
0
 private void InitializeData(CompanyTypes type)
 {
     try
     {
         Cursor = Cursors.WaitCursor;
         dsCore1.EnforceConstraints = false;
         daOrders1.Connection       = AppHelper.GetDbConnection();
         daOrders1.ClearBeforeFill  = true;
         if (type == CompanyTypes.Customer)
         {
             daOrders1.FillOpeningBalanceCustomer(dsCore1.Orders, (DateTime)dtpBegin.Value, ((DateTime)dtpEnd.Value).AddDays(1));
         }
         else
         {
             daOrders1.FillOpeningBalanceVendor(dsCore1.Orders, (DateTime)dtpBegin.Value, ((DateTime)dtpEnd.Value).AddDays(1));
         }
     }
     catch (Exception ex)
     {
         Logger.ErrorRoutine(ex);
         RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message);
     }
     finally
     {
         Cursor = Cursors.Default;
     }
 }
示例#6
0
 /// <summary>
 /// contructor for editing existing account class
 /// </summary>
 public frmUserEntry(int key)
 {
     // This call is required by the Windows Form Designer.
     InitializeComponent();
     InitializeForm();
     // mode
     txMode = DataEntryModes.Edit;
     // Prepare Database
     try
     {
         daUsers.Connection = AppHelper.GetDbConnection();
         daRoles.Connection = AppHelper.GetDbConnection();
         daRoles.FillActive(dsSecurity1.Roles);
         daUsers.FillByID(dsSecurity1.Users, key);
         // password
         DataRowView dr = (DataRowView)this.BindingContext[this.dsSecurity1, "Users"].Current;
         c1TextBox2.Text = SecurityHelper.DecryptText((string)dr["Password"], (string)dr["UserName"]);
         c1TextBox3.Text = SecurityHelper.DecryptText((string)dr["Password"], (string)dr["UserName"]);
     }
     catch (Exception ex)
     {
         RibbonMessageBox.Show("ERROR Initializing Form\n" + ex.Message,
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
示例#7
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     // if database connection modified
     if (c1TextBox3.Text != AppHelper.dbServer || c1TextBox4.Text != AppHelper.dbName ||
         c1TextBox6.Text != AppHelper.dbUser || c1TextBox7.Text != AppHelper.dbPassword)
     {
         AppHelper.dbServer   = c1TextBox3.Text;
         AppHelper.dbName     = c1TextBox4.Text;
         AppHelper.dbUser     = c1TextBox6.Text;
         AppHelper.dbPassword = c1TextBox7.Text;
         dbConnectionModified = true;
     }
     // check for empty username and password
     if (c1TextBox1.Text.Trim() == "" || c1TextBox2.Text.Trim() == "")
     {
         RibbonMessageBox.Show("Username and or Password are required",
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     // try logging in
     else
     {
         loginSucceeded = ValidateUser();
         if (!loginSucceeded)
         {
             RibbonMessageBox.Show("Username and or Password invalid",
                                   Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             Close();
         }
     }
 }
示例#8
0
 public frmOwnerEntry()
 {
     InitializeComponent();
     InitializeForm();
     // access control id
     ModuleID = "ACC-01013";
     // retrieve data
     daCompanies1.Connection      = AppHelper.GetDbConnection();
     daCompanies1.ClearBeforeFill = true;
     try
     {
         // try loading data first
         daCompanies1.FillOwner(this.dsCore1.Companies);
         txMode = DataEntryModes.Edit;
         if (dsCore1.Companies.Rows.Count <= 0)
         {
             txMode = DataEntryModes.Add;
             this.BindingContext[this.dsCore1, "Companies"].AddNew();
             DataRowView dr = (DataRowView)this.BindingContext[this.dsCore1, "Companies"].Current;
             // default field value
             dr["Active"] = 1;
             dr["Code"]   = "OWNER";
             dr["Type"]   = "O";
         }
     }
     catch (Exception ex)
     {
         // textfile logging
         Logger.ErrorRoutine(ex);
         // screen logging
         RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message,
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
示例#9
0
        public frmRoleEntry(int key)
        {
            InitializeComponent();
            InitializeEventHandlers();
            InitializeForm();

            try
            {
                // mode
                txMode = DataEntryModes.Edit;
                // database connection
                daRoles.Connection            = AppHelper.GetDbConnection();
                daApplications.Connection     = AppHelper.GetDbConnection();
                daApplicationRoles.Connection = AppHelper.GetDbConnection();
                // display roles
                mRoleID = key;
                daRoles.FillByID(dsSecurity1.Roles, key);
                daApplications.FillActive(dsSecurity1.Applications);
                daApplicationRoles.FillByRoleID(dsSecurity1.ApplicationRoles, mRoleID);
            }
            catch (Exception ex)
            {
                Logger.ErrorRoutine(ex);
                RibbonMessageBox.Show("Edit existing Role\n" + ex.Message,
                                      Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
示例#10
0
 private void InitializeData(CompanyTypes type)
 {
     try
     {
         Cursor = Cursors.WaitCursor;
         dsCore1.EnforceConstraints   = false;
         daCompanies1.Connection      = AppHelper.GetDbConnection();
         daCompanies1.ClearBeforeFill = true;
         if (type == CompanyTypes.Customer)
         {
             daCompanies1.FillCustomer(dsCore1.Companies);
         }
         else
         {
             daCompanies1.FillVendor(dsCore1.Companies);
         }
     }
     catch (Exception ex)
     {
         Logger.ErrorRoutine(ex);
         RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message);
     }
     finally
     {
         Cursor = Cursors.Default;
     }
 }
 private void InitializeData(int id)
 {
     // main data
     try
     {
         dsCore1.EnforceConstraints = false;
         dsCore2.EnforceConstraints = false;
         // set database connection
         daCurrencies1.Connection   = AppHelper.GetDbConnection();
         daCompanies1.Connection    = AppHelper.GetDbConnection();
         daItems1.Connection        = AppHelper.GetDbConnection();
         daWarehouses1.Connection   = AppHelper.GetDbConnection();
         daOrders1.Connection       = AppHelper.GetDbConnection();
         daOrderDetails1.Connection = AppHelper.GetDbConnection();
         // lookup table
         daCompanies1.FillCustomerActive(dsCore1.Companies);
         daCurrencies1.FillActive(dsCore1.Currencies);
         daOrders1.FillSalesBackOrders(dsCore2.Orders);
         daWarehouses1.FillActive(dsCore1.Warehouses);
         // get data
         if (id < 0)
         {
             // mode
             txMode = DataEntryModes.Add;
             // add new row to master table
             BindingContext[dsCore1, "Orders"].AddNew();
             // default values for master table
             DataRowView dr = (DataRowView)this.BindingContext[dsCore1, "Orders"].Current;
             //dr["OrderNo"] = Orders.GenerateNewID(DateTime.Today.Year, ModulePrefix);
             dr["OrderNo"]      = DbHelper.GenerateNewOrderID(ModulePrefix, DateTime.Today.Year);
             dr["OrderValue"]   = 0;
             dr["OrderType"]    = ModulePrefix;
             dr["OrderDate"]    = DateTime.Today;
             dr["RequiredDate"] = DateTime.Today.AddDays(30);
         }
         else
         {
             // mode
             txMode = DataEntryModes.Edit;
             // get data
             daOrders1.ClearBeforeFill = true;
             daOrders1.FillByID(dsCore1.Orders, id);
             // get details
             daOrderDetails1.ClearBeforeFill = true;
             daOrderDetails1.FillByOrderID(dsCore1.OrderDetails, id);
         }
     }
     catch (Exception ex)
     {
         Logger.ErrorRoutine(ex);
         RibbonMessageBox.Show("ERROR Loading Data: " + ex.Message,
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
示例#12
0
 private bool ValidateUserInput()
 {
     if (Convert.ToDouble(c1Label1.Value) != Convert.ToDouble(c1NumericEdit1.Value))
     {
         RibbonMessageBox.Show("Payment Value must be equals to Total Value from Detail Grid\n",
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return(false);
     }
     // otherwise, successful
     return(true);
 }
示例#13
0
 void _grid_BeforeAddRow(object sender, RowColEventArgs e)
 {
     Cursor = Cursors.AppStarting;
     if (c1Combo1.SelectedValue == null || c1Combo3.SelectedValue == null)
     {
         RibbonMessageBox.Show("Please select customer and set currency type before adding payment details",
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         e.Cancel = true;
     }
     Cursor = Cursors.Default;
 }
示例#14
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.AppStarting;
            DialogResult dr;

            try
            {
                string deleted = "[" + this._grid.Columns["OrderNo"].Text + "] ";
                try
                {
                    dr = RibbonMessageBox.Show("Do you really want to delete data " + deleted,
                                               Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        // delete detail record first
                        // this step is necessary, or otherwise
                        // trigger which update iteminventories will fail
                        DataRowView dv = (DataRowView)this.BindingContext[this.dsCore1, "Orders"].Current;
                        this.daOrders1.DeleteDetails((int)dv["ID"]);
                        this.daOrders1.DeleteMaster((int)dv["ID"]);
                        this.btnRefresh.PerformClick();
                    }
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 547)
                    {
                        RibbonMessageBox.Show("Data " + deleted + " can't be deleted because it's already used as reference",
                                              Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        RibbonMessageBox.Show("Error deleting data\nDetails: " + ex.Message,
                                              Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    dsCore1.RejectChanges();
                    btnRefresh.PerformClick();
                }
                catch (System.Exception ex)
                {
                    RibbonMessageBox.Show("Error deleting data\n" + ex.Message,
                                          Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    dsCore1.RejectChanges();
                    btnRefresh.PerformClick();
                }
            }
            catch
            {
                RibbonMessageBox.Show("No data selected for deletion\n",
                                      Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            Cursor = Cursors.Default;
        }
示例#15
0
 private void c1Combo1_SelectedValueChanged(object sender, EventArgs e)
 {
     if (txMode == DataEntryModes.Add)
     {
         try
         {
             // prevent redraw
             _grid.Redraw = false;
             // get data
             dsCore             ds = new dsCore();
             OrdersTableAdapter od = new OrdersTableAdapter();
             ds.EnforceConstraints = false;
             od.Connection         = AppHelper.GetDbConnection();
             od.FillOutstandingSalesInvoices(ds.Orders, (int)c1Combo1.SelectedValue);
             // clear grid
             dsCore1.OrderDetails.Clear();
             // fill grid with new data
             DataRowView dv = (DataRowView)this.BindingContext[dsCore1, "Orders"].Current;
             foreach (dsCore.OrdersRow src in ds.Orders.Rows)
             {
                 dsCore.OrderDetailsRow row = dsCore1.OrderDetails.NewOrderDetailsRow();
                 row.OrderID        = (int)dv["ID"];
                 row.ReferenceID    = src.ID;
                 row.ReferenceNo    = src.OrderNo;
                 row.ReferenceDate  = src.OrderDate;
                 row.ReferenceValue = src.OutstandingValue;
                 row.UnitPrice      = src.OutstandingValue;
                 row.Quantity       = 1;
                 row.TaxPct         = 0;
                 if (!src.IsRemarksNull())
                 {
                     row.Remarks = src.Remarks;
                 }
                 dsCore1.OrderDetails.AddOrderDetailsRow(row);
             }
             // recalculate
             CountDetails();
             // redraw grid
             _grid.Redraw = true;
             _grid.Refresh();
         }
         catch (Exception ex)
         {
             // textfile logging
             Logger.ErrorRoutine(ex);
             // screen logging
             RibbonMessageBox.Show("ERROR Retrieving Detail Data: \n" + ex.Message,
                                   Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
 }
示例#16
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     this.Cursor = Cursors.AppStarting;
     // qunatity min max checking
     if (!QuantityMinMaxChecking())
     {
         RibbonMessageBox.Show("Base Price, Selling Price, Quantity Minimum and Maximum must be greater than or equal to 0 (zero). " +
                               "Additionally, Quantity Maximum must be greater than or equal to Quantity Minimum",
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     // persist changes
     try
     {
         this.BindingContext[this.dsCore1, "Items"].EndCurrentEdit();
         daItems1.Update(this.dsCore1.Items);
         RibbonMessageBox.Show("Data Changes SUCCESSFULLY Persisted to Database",
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.dsCore1.AcceptChanges();
         // success, close form
         btnClose.PerformClick();
     }
     catch (SqlException ex)
     {
         // textfile logging
         Logger.ErrorRoutine(ex);
         // screen logging
         if (ex.Number != 2601)
         {
             RibbonMessageBox.Show("ERROR Saving Data to Database: \n" + ex.Message,
                                   Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             RibbonMessageBox.Show("ERROR Saving Data to Database: \n" +
                                   "Data with code [" + c1TextBox1.Text + "] already exists in database\n" +
                                   "Please change it and try saving it again.",
                                   Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     catch (Exception ex)
     {
         // textfile logging
         Logger.ErrorRoutine(ex);
         // screen logging
         RibbonMessageBox.Show("ERROR Saving Data to Database: " + ex.Message,
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     this.Cursor = Cursors.Default;
 }
        private void _grid_CellButtonClick(object sender, RowColEventArgs e)
        {
            Cursor = Cursors.AppStarting;
            try
            {
                // open item list form
                if (e.Col == _grid.Cols["ItemCode"].SafeIndex)
                {
                    frmItemSearch fx;
                    if (_grid[e.Row, "ItemCode"] == DBNull.Value)
                    {
                        fx = new frmItemSearch();
                    }
                    else
                    {
                        fx = new frmItemSearch((int)_grid[e.Row, "ItemID"]);
                    }
                    fx.ShowDialog();

                    if (fx.SelectedOK)
                    {
                        dsCore.ItemsDataTable data = daItems1.GetDataByID(fx.SelectedID);
                        // item info
                        if (data.Rows.Count > 0)
                        {
                            // display data
                            _grid.SetData(e.Row, "ItemID", data[0].ID);
                            _grid.SetData(e.Row, "ItemCode", data[0].Code);
                            _grid.SetData(e.Row, "ItemName", data[0].Name);
                            _grid.SetData(e.Row, "MeasureCode", data[0].IsMeasureCodeNull() ? "" : data[0].MeasureCode);
                            _grid.SetData(e.Row, "UnitPrice", data[0].IsSellingPriceNull() ? 0 : data[0].SellingPrice);
                            _grid.SetData(e.Row, "TaxPct", 0);
                            _grid.SetData(e.Row, "TrxType", 0);
                            _grid.SetData(e.Row, "Quantity", 1);
                            // display default remark
                            _grid.SetData(e.Row, "Remarks", c1TextBox2.Text);
                        }
                    }
                }
                // Auto counting for kredit each time
                c1Label1.Value = CountDetails();
            }
            catch (Exception ex)
            {
                Logger.ErrorRoutine(ex);
                RibbonMessageBox.Show("ERROR Adding Detail Items: " + ex.Message,
                                      Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            Cursor = Cursors.Default;
        }
示例#18
0
 private void frmItemEntry_Helper(int id)
 {
     // required by form designer
     InitializeComponent();
     // access control id
     ModuleID = "ACC-01013";
     // retrieve support data
     daItemCategories1.Connection      = AppHelper.GetDbConnection();
     daItemCategories1.ClearBeforeFill = true;
     daItemCategories1.FillActive(dsCore1.ItemCategories);
     daUnitMeasures1.Connection      = AppHelper.GetDbConnection();
     daUnitMeasures1.ClearBeforeFill = true;
     daUnitMeasures1.FillActive(dsCore1.UnitMeasures);
     daCompanies1.Connection      = AppHelper.GetDbConnection();
     daCompanies1.ClearBeforeFill = true;
     daCompanies1.FillVendor(dsCore1.Companies);
     // retrieve main data
     daItems1.Connection      = AppHelper.GetDbConnection();
     daItems1.ClearBeforeFill = true;
     try
     {
         if (id < 0)
         {
             this.BindingContext[this.dsCore1, "Items"].AddNew();
             DataRowView dr = (DataRowView)this.BindingContext[this.dsCore1, "Items"].Current;
             dr["code"]         = DbHelper.GenerateNewItemID();
             dr["Active"]       = 1;
             dr["Inventoried"]  = 1;
             dr["BasePrice"]    = 0;
             dr["SellingPrice"] = 0;
             dr["QuantityMin"]  = 0;
             dr["QuantityMax"]  = 0;
             dr["ExpiryInDays"] = 0;
             txMode             = DataEntryModes.Add;
         }
         else
         {
             daItems1.FillByID(this.dsCore1.Items, id);
             txMode = DataEntryModes.Edit;
         }
     }
     catch (Exception ex)
     {
         // textfile logging
         Logger.ErrorRoutine(ex);
         // screen logging
         RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message,
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
示例#19
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.AppStarting;
            DialogResult dr;

            try
            {
                string deleted = "[" + this._grid.Columns["code"].Text + "] " + this._grid.Columns["name"].Text;
                try
                {
                    dr = RibbonMessageBox.Show("Do you really want to delete data " + deleted,
                                               Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        this.BindingContext[this.dsCore1, "Companies"].RemoveAt(this.BindingContext[this.dsCore1, "Companies"].Position);
                        this.daCompanies1.Update(this.dsCore1.Companies);
                        this.dsCore1.AcceptChanges();
                    }
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 547)
                    {
                        RibbonMessageBox.Show("Data " + deleted + " can't be deleted because it's already used as reference",
                                              Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        RibbonMessageBox.Show("Error deleting data\nDetails: " + ex.Message,
                                              Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    dsCore1.RejectChanges();
                    btnRefresh.PerformClick();
                }
                catch (System.Exception ex)
                {
                    RibbonMessageBox.Show("Error deleting data\n" + ex.Message,
                                          Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    dsCore1.RejectChanges();
                    btnRefresh.PerformClick();
                }
            }
            catch
            {
                RibbonMessageBox.Show("No data selected for deletion\n",
                                      Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            Cursor = Cursors.Default;
        }
示例#20
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     Cursor = Cursors.AppStarting;
     try
     {
         Form fx = new frmCompanyEntry(type, (int)_grid.Columns["id"].Value);
         fx.ShowDialog();
         btnRefresh.PerformClick();
     }
     catch
     {
         RibbonMessageBox.Show("No data selected for editing\n",
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     Cursor = Cursors.Default;
 }
示例#21
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     Cursor = Cursors.AppStarting;
     try
     {
         Form fx = new frmDeliveryOrderEntry((int)_grid.Columns["id"].Value);
         fx.ShowDialog();
         btnRefresh.PerformClick();
     }
     catch (Exception ex)
     {
         Logger.ErrorRoutine(ex);
         RibbonMessageBox.Show("No data selected for editing\n",
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     Cursor = Cursors.Default;
 }
 private bool ValidateUserInput()
 {
     if (c1Combo1.SelectedValue == null || c1Combo3.SelectedValue == null)
     {
         RibbonMessageBox.Show("Please select Vendor and set Currency Type before saving data",
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return(false);
     }
     if (radioButton1.Checked && Convert.ToDouble(c1Label1.Value) != Convert.ToDouble(c1NumericEdit1.Value))
     {
         RibbonMessageBox.Show("Payment Value must be equals to Purchase Order value \n",
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return(false);
     }
     // otherwise, successful
     return(true);
 }
示例#23
0
 private void InitializeData()
 {
     try
     {
         dsCore1.EnforceConstraints = false;
         daOrders1.Connection       = AppHelper.GetDbConnection();
         daOrders1.ClearBeforeFill  = true;
         daOrders1.FillPurchaseInvoice(dsCore1.Orders, (DateTime)dtpBegin.Value, ((DateTime)dtpEnd.Value).AddDays(1));
     }
     catch (Exception ex)
     {
         Logger.ErrorRoutine(ex);
         RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message);
     }
     finally
     {
         Cursor = Cursors.Default;
     }
 }
示例#24
0
 private void InitializeData()
 {
     try
     {
         dsCore1.EnforceConstraints = false;
         itemInventoriesTableAdapter1.Connection      = AppHelper.GetDbConnection();
         itemInventoriesTableAdapter1.ClearBeforeFill = true;
         itemInventoriesTableAdapter1.FillDenormalized(dsCore1.ItemInventories);
     }
     catch (Exception ex)
     {
         Logger.ErrorRoutine(ex);
         RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message);
     }
     finally
     {
         Cursor = Cursors.Default;
     }
 }
示例#25
0
 private void InitializeData()
 {
     try
     {
         dsSecurity1.EnforceConstraints = false;
         daUsers1.Connection            = AppHelper.GetDbConnection();
         daUsers1.ClearBeforeFill       = true;
         daUsers1.Fill(dsSecurity1.Users);
     }
     catch (Exception ex)
     {
         Logger.ErrorRoutine(ex);
         RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message);
     }
     finally
     {
         Cursor = Cursors.Default;
     }
 }
示例#26
0
 public frmRoleEntry()
 {
     InitializeComponent();
     InitializeEventHandlers();
     InitializeForm();
     // Prepare Database
     try
     {
         // mode
         txMode = DataEntryModes.Add;
         // add new row to dataset
         BindingContext[dsSecurity1, "Roles"].AddNew();
         DataRowView dr = (DataRowView)this.BindingContext[this.dsSecurity1, "Roles"].Current;
         dr["Active"] = 1;
         // database connection
         daRoles.Connection            = AppHelper.GetDbConnection();
         daApplications.Connection     = AppHelper.GetDbConnection();
         daApplicationRoles.Connection = AppHelper.GetDbConnection();
         // fill flexgrid data
         daApplications.FillActive(dsSecurity1.Applications);
         this.BindingContext[dsSecurity1, "Roles"].EndCurrentEdit();
         foreach (dsSecurity.ApplicationsRow src in dsSecurity1.Applications)
         {
             dsSecurity.ApplicationRolesRow row = dsSecurity1.ApplicationRoles.NewApplicationRolesRow();
             row.RoleID          = (int)dr["ID"];
             row.ApplicationID   = src.ID;
             row.ApplicationCode = src.Code;
             row.ApplicationName = src.Name;
             row.AllowRead       = true;
             row.AllowCreate     = true;
             row.AllowUpdate     = true;
             row.AllowDelete     = true;
             dsSecurity1.ApplicationRoles.AddApplicationRolesRow(row);
         }
     }
     catch (Exception ex)
     {
         Logger.ErrorRoutine(ex);
         RibbonMessageBox.Show("Creating new Role\n" + ex.Message,
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
示例#27
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     this.Cursor = Cursors.AppStarting;
     try
     {
         this.BindingContext[this.dsCore1, "Warehouses"].EndCurrentEdit();
         daWarehouses1.Update(this.dsCore1.Warehouses);
         RibbonMessageBox.Show("Data Changes SUCCESSFULLY Persisted to Database",
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.dsCore1.AcceptChanges();
         // success, close form
         btnClose.PerformClick();
     }
     catch (SqlException ex)
     {
         // textfile logging
         Logger.ErrorRoutine(ex);
         // screen logging
         if (ex.Number != 2601)
         {
             RibbonMessageBox.Show("ERROR Saving Data to Database: \n" + ex.Message,
                                   Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             RibbonMessageBox.Show("ERROR Saving Data to Database: \n" +
                                   "Data with code [" + c1TextBox1.Text + "] already exists in database\n" +
                                   "Please change it and try saving it again.",
                                   Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     catch (Exception ex)
     {
         // textfile logging
         Logger.ErrorRoutine(ex);
         // screen logging
         RibbonMessageBox.Show("ERROR Saving Data to Database: " + ex.Message,
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     this.Cursor = Cursors.Default;
 }
示例#28
0
 /// <summary>
 /// This function will read from database based on current user
 /// and then will display all aplication menu button allowed for that user
 /// </summary>
 private void ShowAllowedMenus()
 {
     try
     {
         dsSecurity1.EnforceConstraints = false;
         daApplicationRoles.Connection  = AppHelper.GetDbConnection();
         daApplicationRoles.FillByUserID(dsSecurity1.ApplicationRoles, AppHelper.appUserID);
         foreach (dsSecurity.ApplicationRolesRow row in dsSecurity1.ApplicationRoles.Rows)
         {
             if (row.AllowRead)
             {
                 ShowMenu(row.ApplicationCode);
             }
         }
     }
     catch (Exception ex)
     {
         Logger.ErrorRoutine(ex);
         RibbonMessageBox.Show("Kesalahan terjadi saat inisialisasi menu aplikasi: " + ex.Message,
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
示例#29
0
        protected override void OnClosing(CancelEventArgs e)
        {
            DialogResult res;

            res = RibbonMessageBox.Show("Do you want to quit " + Application.ProductName + "?",
                                        Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                e.Cancel = false;
            }
            else
            {
                e.Cancel = true;
            }

            if (!e.Cancel)
            {
                Logger.DebugRoutine("Application Closed.\n=====================================\n\n");
            }

            base.OnClosing(e);
        }
示例#30
0
 /// <summary>
 /// contructor for add new account class
 /// </summary>
 public frmUserEntry()
 {
     // This call is required by the Windows Form Designer.
     InitializeComponent();
     InitializeForm();
     // mode
     txMode = DataEntryModes.Add;
     // Prepare Database
     try
     {
         daUsers.Connection = AppHelper.GetDbConnection();
         daRoles.Connection = AppHelper.GetDbConnection();
         daRoles.FillActive(dsSecurity1.Roles);
         this.BindingContext[dsSecurity1, "Users"].AddNew();
         DataRowView dr = (DataRowView)this.BindingContext[this.dsSecurity1, "Users"].Current;
         dr["Active"] = 1;
     }
     catch (Exception ex)
     {
         RibbonMessageBox.Show("ERROR Initializing Form\n" + ex.Message,
                               Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }