Exemplo n.º 1
0
        public bool Save()
        {
            try
            {
                int rowsAffected = ADODatabase.ExecuteNonQuery("UPDATE FillingLineData SET IsDefault = 1 WHERE FillingLineID = " + (int)this.FillingLineID + " AND ProductID = " + this.ProductID);


                if (rowsAffected <= 0) //Add New
                {
                    rowsAffected = ADODatabase.ExecuteTransaction("UPDATE FillingLineData SET IsDefault = 0 WHERE FillingLineID = " + (int)this.FillingLineID + "; " +
                                                                  "INSERT INTO FillingLineData (FillingLineID, ProductID, BatchNo, SettingDate, SettingMonthID, BatchSerialNumber, MonthSerialNumber, BatchCartonNumber, MonthCartonNumber, Remarks, LastSettingDate, LastSerialDate, IsDefault) " +
                                                                  "VALUES (" + (int)this.FillingLineID + ", " + this.ProductID + ", N'" + this.BatchNo + "', CONVERT(smalldatetime, '" + this.SettingDate.ToString("dd/MM/yyyy") + "',103), " + this.SettingMonthID.ToString() + ", N'" + this.BatchSerialNumber + "', N'" + this.MonthSerialNumber + "', N'" + this.BatchCartonNumber + "', N'" + this.MonthCartonNumber + "', N'" + this.Remarks + "', GetDate(), GetDate(), 1) ");

                    return(rowsAffected > 0);
                }

                else //Update Only
                {
                    return(Update());
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Exemplo n.º 2
0
        public FillingLineData()
        {
            DataTable defaultFillingLineData = ADODatabase.GetDataTable("SELECT FillingLineData.ProductID, ListProductName.ProductCode, ListProductName.ProductCodeOriginal, ListProductName.NoItemPerCarton, FillingLineData.BatchNo, FillingLineData.SettingDate, FillingLineData.SettingMonthID, FillingLineData.BatchSerialNumber, FillingLineData.MonthSerialNumber, FillingLineData.BatchCartonNumber, FillingLineData.MonthCartonNumber FROM FillingLineData INNER JOIN ListProductName ON FillingLineData.ProductID = ListProductName.ProductID WHERE FillingLineData.FillingLineID = " + (int)this.FillingLineID + " AND FillingLineData.IsDefault = 1");

            if (defaultFillingLineData.Rows.Count > 0)
            {
                this.StartTracking();

                this.ProductID           = int.Parse(defaultFillingLineData.Rows[0]["ProductID"].ToString());
                this.ProductCode         = defaultFillingLineData.Rows[0]["ProductCode"].ToString();
                this.ProductCodeOriginal = defaultFillingLineData.Rows[0]["ProductCodeOriginal"].ToString();

                GlobalVariables.noItemPerCartonSetByProductID = int.Parse(defaultFillingLineData.Rows[0]["NoItemPerCarton"].ToString());



                int noItem = 0;
                GlobalVariables.noItemPerCartonSetByProductID = int.TryParse(GlobalRegistry.Read("NoItemPerCartonSetByProductID"), out noItem) ? noItem : 0;



                this.BatchNo = defaultFillingLineData.Rows[0]["BatchNo"].ToString();

                this.SettingDate    = DateTime.Parse(defaultFillingLineData.Rows[0]["SettingDate"].ToString());
                this.SettingMonthID = int.Parse(defaultFillingLineData.Rows[0]["SettingMonthID"].ToString());

                this.BatchSerialNumber = defaultFillingLineData.Rows[0]["BatchSerialNumber"].ToString();
                this.MonthSerialNumber = defaultFillingLineData.Rows[0]["MonthSerialNumber"].ToString();

                this.BatchCartonNumber = defaultFillingLineData.Rows[0]["BatchCartonNumber"].ToString();
                this.MonthCartonNumber = defaultFillingLineData.Rows[0]["MonthCartonNumber"].ToString();

                this.StartTracking();
            }
        }
Exemplo n.º 3
0
        public SettingFillingLineData(FillingLineData fillingLineData, bool isMessageQueueEmpty)
        {
            InitializeComponent();

            this.globalFillingLineData  = fillingLineData;
            this.privateFillingLineData = fillingLineData.ShallowClone();


            DataTable dataTable = ADODatabase.GetDataTable("SELECT ProductID, ProductCode, ProductCodeOriginal, ProductName, ProductCode + '    [' + ProductCodeOriginal + '] ' + ProductName AS ProductDisplayName FROM ListProductName");

            this.comboBoxProductID.DataSource    = dataTable;
            this.comboBoxProductID.ValueMember   = "ProductID";
            this.comboBoxProductID.DisplayMember = "ProductDisplayName";


            fillingLineNameBinding = this.textBoxFillingLineName.DataBindings.Add("Text", this.privateFillingLineData, "FillingLineName", true);
            productIDBinding       = this.comboBoxProductID.DataBindings.Add("SelectedValue", this.privateFillingLineData, "ProductID", true, DataSourceUpdateMode.OnPropertyChanged);

            batchNoBinding     = this.textBoxBatchNo.DataBindings.Add("Text", this.privateFillingLineData, "BatchNo", true);
            settingDateBinding = this.dateTimePickerSettingDate.DataBindings.Add("Value", this.privateFillingLineData, "SettingDate", true, DataSourceUpdateMode.OnPropertyChanged);

            batchSerialNumberBinding = this.textBoxBatchSerialNumber.DataBindings.Add("Text", this.privateFillingLineData, "BatchSerialNumber", true);
            monthSerialNumberBinding = this.textBoxMonthSerialNumber.DataBindings.Add("Text", this.privateFillingLineData, "MonthSerialNumber", true);

            batchCartonNumberBinding = this.textBoxBatchCartonNumber.DataBindings.Add("Text", this.privateFillingLineData, "BatchCartonNumber", true);
            monthCartonNumberBinding = this.textBoxMonthCartonNumber.DataBindings.Add("Text", this.privateFillingLineData, "MonthCartonNumber", true);


            fillingLineNameBinding.BindingComplete += new BindingCompleteEventHandler(fillingLineNameBinding_BindingComplete);
            productIDBinding.BindingComplete       += new BindingCompleteEventHandler(productIDBinding_BindingComplete);

            batchNoBinding.BindingComplete     += new BindingCompleteEventHandler(batchNoBinding_BindingComplete);
            settingDateBinding.BindingComplete += new BindingCompleteEventHandler(settingDateBinding_BindingComplete);

            batchSerialNumberBinding.BindingComplete += new BindingCompleteEventHandler(batchSerialNumberBinding_BindingComplete);
            monthSerialNumberBinding.BindingComplete += new BindingCompleteEventHandler(monthSerialNumberBinding_BindingComplete);

            batchCartonNumberBinding.BindingComplete += new BindingCompleteEventHandler(batchCartonNumberBinding_BindingComplete);
            monthCartonNumberBinding.BindingComplete += new BindingCompleteEventHandler(monthCartonNumberBinding_BindingComplete);

            this.privateFillingLineData.PropertyChanged += new PropertyChangedEventHandler(privateFillingLineData_PropertyChanged);

            this.comboBoxProductID.Enabled = isMessageQueueEmpty;
        }
Exemplo n.º 4
0
        private void UpdateProductName()
        {
            DataTable dataTable = ((DataTable)bindingSource.DataSource).GetChanges(DataRowState.Added); int rowsAdded = 0;

            if (dataTable != null)
            {
                rowsAdded = dataTable.Rows.Count;
            }
            int rowsAffected = sqlDataAdapter.Update((DataTable)bindingSource.DataSource);

            if (rowsAffected != 0)
            {
                ADODatabase.ExecuteNonQuery("UPDATE ListFillingLineName SET ListProductNameRowsAffected = ListProductNameRowsAffected + " + rowsAffected);
                if (rowsAdded > 0)
                {
                    this.LoadProductList();
                }
            }
        }
Exemplo n.º 5
0
        private void LoadProductList()
        {
            try
            {
                sqlDataAdapter = new SqlDataAdapter("SELECT * FROM ListProductName", ADODatabase.Connection());

                // Create a command builder to generate SQL update, insert, and delete commands based on selectCommand. These are used to update the database.
                SqlCommandBuilder commandBuilder = new SqlCommandBuilder(sqlDataAdapter);

                // Populate a new data table and bind it to the BindingSource.
                DataTable dataTable = new DataTable();
                dataTable.Locale = System.Globalization.CultureInfo.InvariantCulture;
                sqlDataAdapter.Fill(dataTable);
                bindingSource.DataSource = dataTable;
            }
            catch (Exception exception)
            {
                GlobalExceptionHandler.ShowExceptionMessageBox(this, exception);
            }
        }
Exemplo n.º 6
0
 public bool Update()
 {
     try
     {
         int rowsAffected = ADODatabase.ExecuteTransaction("UPDATE FillingLineData SET IsDefault = 0 WHERE FillingLineID = " + (int)this.FillingLineID + "; " +
                                                           "UPDATE FillingLineData SET BatchNo = N'" + this.BatchNo.ToString() + "', " +
                                                           " SettingDate = CONVERT(smalldatetime, '" + this.SettingDate.ToString("dd/MM/yyyy") + "', 103), " +
                                                           " SettingMonthID = " + this.SettingMonthID.ToString() + ", " +
                                                           " BatchSerialNumber = N'" + this.BatchSerialNumber.ToString() + "', " +
                                                           " MonthSerialNumber = N'" + this.MonthSerialNumber.ToString() + "', " +
                                                           " BatchCartonNumber = N'" + this.BatchCartonNumber.ToString() + "', " +
                                                           " MonthCartonNumber = N'" + this.MonthCartonNumber.ToString() + "', " +
                                                           " LastSerialDate = GetDate(), IsDefault = 1 " +
                                                           "WHERE FillingLineID   =  " + (int)this.FillingLineID + " AND ProductID = " + this.ProductID);
         return(rowsAffected > 0);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }