Example #1
0
        public void editIngredient()
        {
            AuntRosieEntities.Ingredient updateIngredient = new AuntRosieEntities.Ingredient();

            updateIngredient.Name        = txtNewIngredintName.Text;
            updateIngredient.StoringNote = txtstoringNote.Text;
            updateIngredient.Unit        = cmbUnit.Text.Trim();


            AuntRosieApplication.Classes.ListItem itm2 = new AuntRosieApplication.Classes.ListItem();
            object obj2 = cmbName.Items[cmbName.SelectedIndex];

            itm2 = (AuntRosieApplication.Classes.ListItem)obj2;
            updateIngredient.Id = (long)Convert.ToDouble(itm2.id);

            try
            {
                DBConnector conn = new DBConnector(Classes.DBMethod.GetConnectionString());
                RosieEntity.Connector = conn;
                updateIngredient.Update();

                MessageBox.Show("The Ingredient has been updated successfully", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                // MessageBox.Show("Sorry! An internal error has happened", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btnNewIngredintSave_Click(object sender, EventArgs e)
        {
            Ingredient newIngredient = new Ingredient();

            if (IsValidIngredent())
            {
                newIngredient.Name             = txtNewIngredintName.Text.Trim();
                newIngredient.Unit             = cmbUnit.Text.Trim();
                newIngredient.IngredientTypeId = (short)Convert.ToDouble(DBMethod.GetSelectedItemID(cmbNewtype));
                newIngredient.StoringNote      = txtstoringNote.Text;
                newIngredient.Unit             = cmbUnit.Text.Trim();
                DBConnector conn = new DBConnector(Classes.DBMethod.GetConnectionString());
                RosieEntity.Connector = conn;
                newIngredient.Create();
                pnlNewIngredint.Visible = false;
                pnlMain.Enabled         = true;

                cmbType.Items.Clear();
                Classes.DBMethod.FillCombBox(AuntRosieEntities.IngredientType.GetAllIngredintType
                                                 (Classes.DBMethod.GetConnectionString()), cmbType);

                AuntRosieApplication.Classes.ListItem itm = new AuntRosieApplication.Classes.ListItem();
                Object obj = cmbType.Items[cmbNewtype.SelectedIndex];
                itm = (Classes.ListItem)obj;

                cmbType.SelectedItem = itm;

                cmbName.SelectedItem = cmbName.Items[cmbName.Items.Count - 1];
            }
        }
Example #3
0
        private void newSupplier()
        {
            AuntRosieEntities.Supplier insertSupplier = new AuntRosieEntities.Supplier();
            insertSupplier.Name             = txtName.Text.Trim();
            insertSupplier.ContactFirstName = txtSupplierFirstName.Text.Trim();
            insertSupplier.ContactLasttName = txtSupplierLastName.Text.Trim();
            insertSupplier.Phone            = txtPhone.Text.Trim();
            insertSupplier.Email            = txtEmail.Text.Trim();
            insertSupplier.City             = txtCity.Text.Trim();
            AuntRosieApplication.Classes.ListItem itm = new AuntRosieApplication.Classes.ListItem();
            Object obj = cmbProvinces.Items[cmbProvinces.SelectedIndex];

            itm = (AuntRosieApplication.Classes.ListItem)obj;
            insertSupplier.Province   = itm.id;
            insertSupplier.Street     = txtStreet.Text.Trim();
            insertSupplier.PostalCode = txtPostalCode.Text.Trim();

            try {
                DBConnector conn = new DBConnector(Classes.DBMethod.GetConnectionString());
                RosieEntity.Connector = conn;
                insertSupplier.Create();

                MessageBox.Show("The new supplier has been inserted successfully", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex) {
                //MessageBox.Show(ex.Message);
                MessageBox.Show("Sorry! An internal error has happened", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void FillCombBoxEvent(DataTable dt, ComboBox cmb)
 {
     if (dt != null)
     {
         foreach (DataRow row in dt.Rows)
         {
             AuntRosieApplication.Classes.ListItem itm = new AuntRosieApplication.Classes.ListItem();
             itm.name = row[1].ToString() + "--ON " + DateTime.Parse(row[2].ToString()).ToLongDateString();
             itm.id   = row[0].ToString();
             cmb.Items.Add((Object)itm);
         }
     }
 }
Example #5
0
        private void GetPaymentDate()
        {
            SqlConnection dbConnection = new SqlConnection(DBMethod.GetConnectionString());

            // Create new SQL command
            SqlCommand command = new SqlCommand("SELECT DISTINCT PaymentDate AS Expr1 FROM  [tblFullTimePayroll]", dbConnection);

            SqlDataAdapter adapter = new SqlDataAdapter(command);

            // Declare a DataTable object that will hold the return value
            DataTable dt = new DataTable();

            // Try to connect to the database, and use the adapter to fill the table
            try
            {
                dbConnection.Open();
                adapter.Fill(dt);

                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("No previous payroll are registered", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    radNew.Checked    = true;
                    radExists.Checked = false;
                }
                else
                {
                    cmbPaymentDate.Enabled = true;
                    cmbPaymentDate.Focus();
                }
                if (dt != null)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        DateTime date = DateTime.Parse(row[0].ToString());
                        AuntRosieApplication.Classes.ListItem itm = new AuntRosieApplication.Classes.ListItem();
                        itm.name = date.Date.ToShortDateString();
                        itm.id   = date.Date.ToShortDateString();
                        cmbPaymentDate.Items.Add((Object)itm);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                dbConnection.Close();
            }
        }
Example #6
0
        private void editEmployee()
        {
            AuntRosieEntities.Employee updateEmployee = new AuntRosieEntities.Employee();


            updateEmployee.FirstName = txtFirstName.Text.Trim();
            updateEmployee.LastName  = txtLastName.Text.Trim();
            updateEmployee.Phone     = txtPhone.Text.Trim();
            updateEmployee.Email     = txtEmail.Text.Trim();
            updateEmployee.City      = txtCity.Text.Trim();
            AuntRosieApplication.Classes.ListItem itm = new AuntRosieApplication.Classes.ListItem();
            Object obj = cmbProvinces.Items[cmbProvinces.SelectedIndex];

            itm = (AuntRosieApplication.Classes.ListItem)obj;
            updateEmployee.Province   = itm.id;
            updateEmployee.Street     = txtStreet.Text.Trim();
            updateEmployee.PostalCode = txtPostalCode.Text.Trim();
            AuntRosieApplication.Classes.ListItem itm2 = new AuntRosieApplication.Classes.ListItem();
            object obj2 = cmbName.Items[cmbName.SelectedIndex];

            itm2 = (AuntRosieApplication.Classes.ListItem)obj2;
            updateEmployee.Id = (long)Convert.ToDouble(itm2.id);
            if (EmpType == "F")
            {
                updateEmployee.Salary         = Convert.ToDouble(txtsalary.Text.Trim());
                updateEmployee.EmploymentDate = dtpEmploymentDate.Value.Date;
            }

            try
            {
                DBConnector conn = new DBConnector(Classes.DBMethod.GetConnectionString());
                RosieEntity.Connector = conn;
                updateEmployee.Update();

                MessageBox.Show("The Employee has been updated successfully", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //MessageBox.Show("Sorry! An internal error has happened", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #7
0
        private void cmbSupplierName_SelectedIndexChanged(object sender, EventArgs e)
        {
            DBConnector conn = new DBConnector(Classes.DBMethod.GetConnectionString());

            RosieEntity.Connector = conn;
            Supplier supplier = Supplier.Retrieve(DBMethod.GetSelectedItemID(cmbSupplierName));

            txtName.Text = supplier.Name;
            txtSupplierFirstName.Text = supplier.ContactFirstName;
            txtSupplierLastName.Text  = supplier.ContactLasttName;
            txtPhone.Text             = supplier.Phone;
            txtEmail.Text             = supplier.Email;
            txtCity.Text = supplier.City;
            AuntRosieApplication.Classes.ListItem itm2 = new AuntRosieApplication.Classes.ListItem();
            itm2.id   = supplier.Province;
            itm2.name = Classes.DBMethod.GetProvinceName(itm2.id);
            cmbProvinces.SelectedItem = itm2;
            cmbProvinces.Text         = Classes.DBMethod.GetProvinceName(itm2.id);
            txtStreet.Text            = supplier.Street;
            txtPostalCode.Text        = supplier.PostalCode;
        }
Example #8
0
        private void cmbName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                DBConnector conn = new DBConnector(Classes.DBMethod.GetConnectionString());
                RosieEntity.Connector = conn;
                Employee employee = Employee.Retrieve(DBMethod.GetSelectedItemID(cmbName));


                txtFirstName.Text = employee.FirstName;
                txtLastName.Text  = employee.LastName;
                txtPhone.Text     = employee.Phone;
                txtEmail.Text     = employee.Email;
                txtCity.Text      = employee.City;
                AuntRosieApplication.Classes.ListItem itm2 = new AuntRosieApplication.Classes.ListItem();
                itm2.id   = employee.Province;
                itm2.name = Classes.DBMethod.GetProvinceName(itm2.id);
                cmbProvinces.SelectedItem = itm2;
                cmbProvinces.Text         = Classes.DBMethod.GetProvinceName(itm2.id);
                txtStreet.Text            = employee.Street;
                txtPostalCode.Text        = employee.PostalCode;
                if (employee.Type == "F")
                {
                    radFullTime.Checked     = true;
                    txtsalary.Text          = employee.Salary.ToString();
                    dtpEmploymentDate.Value = employee.EmploymentDate.Date;
                }
                else
                {
                    txtsalary.Text          = "";
                    dtpEmploymentDate.Value = DateTime.Today.Date;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Example #9
0
        public void deleteIngredient()
        {
            Ingredient deleteIngredient = new Ingredient();

            AuntRosieApplication.Classes.ListItem itm2 = new AuntRosieApplication.Classes.ListItem();
            object obj2 = cmbName.Items[cmbName.SelectedIndex];

            itm2 = (AuntRosieApplication.Classes.ListItem)obj2;
            deleteIngredient.Id = (long)Convert.ToDouble(itm2.id);

            try
            {
                DBConnector conn = new DBConnector(Classes.DBMethod.GetConnectionString());
                RosieEntity.Connector = conn;
                deleteIngredient.Delete();

                MessageBox.Show("The Ingredient has been deleted successfully", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show("This ingredients could not be deleted", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }