Exemple #1
0
        private void SetButchersLabels()
        {
            var sqlConn = new SqlConn(DbConnectionString());

            try
            {
                if (sqlConn.TestConnection())
                {
                    var sqlDatatable = new SqlDataTable();
                    var dt           = new DataTable();
                    var sqlQuery     = string.Empty;

                    sqlQuery = "SELECT * FROM tblCustomer";
                    dt       = SqlDataTable.GetDatatable(sqlConn.GetSqlConnection(), sqlQuery);
                    SetControlsLookUpEdit(lookUpEdit_Customer, dt, "CustomerName", "IdCustomer", "Customer");

                    sqlQuery = "SELECT * FROM tblShift";
                    dt       = SqlDataTable.GetDatatable(sqlConn.GetSqlConnection(), sqlQuery);
                    SetControlsLookUpEdit(lookUpEdit_Shift, dt, "Shift", "IdShift", "Shift");

                    lookUpEdit_Product.Enabled = false;
                }
                else
                {
                    throw new Exception("Unexpected error when tried to connect to server and download data.");
                }
            }
            catch (Exception Ex)
            {
                var message = string.Format(Ex.Message);
                var title   = "Database connection";
                XtraMessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        private void GetDataFromSI(string barCode)
        {
            var       sqlConn = new SqlConn(SIConnectionString());
            DataTable dt      = new DataTable();

            try
            {
                if (sqlConn.TestConnection())
                {
                    var    sqlQuery    = string.Empty;
                    string batchPallet = string.Empty;

                    switch (barCode.Length)
                    {
                    case 14:
                        batchPallet    = barCode.Substring(2);
                        _batchOrPallet = SqlQueryBatchPallet.PalletBatchField.palletid;
                        sqlQuery       = SqlQueryBatchPallet.SelectPalletBatch(_batchOrPallet, batchPallet);
                        break;

                    case 22:
                        batchPallet    = barCode.Substring(0, 12);
                        _batchOrPallet = SqlQueryBatchPallet.PalletBatchField.batchno;
                        sqlQuery       = SqlQueryBatchPallet.SelectPalletBatch(_batchOrPallet, batchPallet);
                        break;

                    default:
                        batchPallet    = barCode;
                        _batchOrPallet = SqlQueryBatchPallet.PalletBatchField.batchno;
                        sqlQuery       = SqlQueryBatchPallet.SelectPalletBatch(_batchOrPallet, batchPallet);
                        break;
                    }

                    if (_butcherLabelsTable != null)
                    {
                        dt = SqlDataTable.GetDatatable(sqlConn.GetSqlConnection(), sqlQuery);
                        _butcherLabelsTable.Merge(dt);
                    }
                    else
                    {
                        dt = SqlDataTable.GetDatatable(sqlConn.GetSqlConnection(), sqlQuery);
                        _butcherLabelsTable = dt;
                    }
                    AddDataToGridView(dt);
                }
                else
                {
                    throw new Exception("Unexpected error when tried to connect to SI database and download data.");
                }
            }
            catch (Exception ex)
            {
                var message = string.Format(ex.Message);
                var title   = "SI database connection";
                XtraMessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
 private void ConnectionTest(SqlConn conn)
 {
     if (!conn.TestConnection())
     {
         XtraMessageBox.Show("Connection test failed.", "Connection test", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         XtraMessageBox.Show("Connection test successful.", "Connection test", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }