Пример #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                ClassLibrary.Customer customer = new ClassLibrary.Customer();

                object  id          = dataGridView1.CurrentRow.Cells["CUSTOMER_id"].Value;
                DataRow selectedRow = dtCustomers.Rows.Find(id);

                DialogResult dlgResult = MessageBox.Show
                                             ("Are you sure you want to delete selected customer and all of his orders",
                                             "Continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (dlgResult == DialogResult.Yes)
                {
                    customer.Id = Convert.ToInt32(id);
                    customer.Delete();
                    displayAllCustomers();
                }
                else if (dlgResult == DialogResult.No)
                {
                    // No, stop
                }
            }
            catch (Exception ex)
            {
                DialogResult dlgResult = MessageBox.Show
                                             ("Cant delete the record!",
                                             "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #2
0
        public Startup(IHostingEnvironment env)
        {
            System.Console.WriteLine(env.EnvironmentName);

            var dt = new Models.DevTool();

            dt.toolName      = "Visual Studio Code";
            dt.twitterHandle = "@code";

            var    c     = new ClassLibrary.Customer("John", "Papa");
            var    fname = c.FirstName;
            string msg;

            msg = "why, hello there! hello back at ya!";

            logInfo("hello asp.net world! " + dt.toolName + " is the tool name");

            // Setup configuration sources.
            var configuration = new Configuration()
                                .AddJsonFile("config.json")
                                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            if (env.IsEnvironment("Development"))
            {
                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                configuration.AddUserSecrets();
            }
            configuration.AddEnvironmentVariables();
            Configuration = configuration;
        }
Пример #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (
                (txtCUSTOMER_name.Text == "") ||
                (txtCUSTOMER_phone.Text == "") ||
                (txtCUSTOMER_address.Text == "") ||
                (txtCUSTOMER_email.Text == "")
                )
            {
                MessageBox.Show("please fill all the empty fields");
            }
            else if (!Regex.IsMatch(txtCUSTOMER_email.Text, "^[\\w-]+@([\\w-]+\\.)+[\\w-]+$"))
            {
                MessageBox.Show("please enter a valid email address");
            }
            else if (!Regex.IsMatch(txtCUSTOMER_phone.Text, "(^(\\+?\\-? *[0-9]+)([,0-9 ]*)([0-9 ])*$)|(^ *$)"))
            {
                MessageBox.Show("please enter a valid phone number");
            }
            else
            {
                ClassLibrary.Customer customer = new ClassLibrary.Customer();
                customer.Name    = txtCUSTOMER_name.Text;
                customer.Phone   = txtCUSTOMER_phone.Text;
                customer.Address = txtCUSTOMER_address.Text;
                customer.Email   = txtCUSTOMER_email.Text;

                //add mode
                if (drCustomer == null)
                {
                    int id = customer.Add();
                    //MessageBox.Show(id.ToString());
                }

                //edit mode
                else
                {
                    customer.Id = Convert.ToInt32(drCustomer.ItemArray[0]);
                    int id = customer.Update();
                    //MessageBox.Show(id.ToString());
                }

                //refresh the disCustomer form
                disCustForm.displayAllCustomers();

                Close();
            }
        }
Пример #4
0
        public void displayAllCustomers()
        {
            ClassLibrary.Customer customer = new ClassLibrary.Customer();

            dtCustomers = customer.GetAll().Tables[0];

            //set the customer_id column as primary key so you can search the table later
            dtCustomers.PrimaryKey   = new DataColumn[] { dtCustomers.Columns["CUSTOMER_id"] };
            dataGridView1.DataSource = dtCustomers;

            dataGridView1.Columns["CUSTOMER_id"].HeaderText      = "ID";
            dataGridView1.Columns["CUSTOMER_name"].HeaderText    = "Name";
            dataGridView1.Columns["CUSTOMER_phone"].HeaderText   = "Phone";
            dataGridView1.Columns["CUSTOMER_email"].HeaderText   = "Email";
            dataGridView1.Columns["CUSTOMER_address"].HeaderText = "Address";
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }
Пример #5
0
        //----------------------------------------------------------------------------------------------
        private void frmAddOrderCustomer_Load(object sender, EventArgs e)
        {
            //make order list
            ord = new BindingList <OrderDetails>();

            //add customers to the combobox
            ClassLibrary.Customer customer = new ClassLibrary.Customer();
            dsCustomer = customer.GetAll();
            dtCustomer = dsCustomer.Tables[0];
            cmbCustomers.DataSource    = dtCustomer;
            cmbCustomers.DisplayMember = "CUSTOMER_name";
            cmbCustomers.ValueMember   = "CUSTOMER_id";

            //add products to the combobox
            ClassLibrary.Product product = new ClassLibrary.Product();
            dsProduct = product.GetAll();
            dtProduct = dsProduct.Tables[0];
            cmbProducts.DataSource    = dtProduct;
            cmbProducts.DisplayMember = "PRODUCT_name";

            //ADDING MODE
            if (drOrder == null)
            {
                dateTimePicker1.Enabled = false;
            }
            //EDITING MODE
            else
            {
                //if orderid is in the sorder table
                ClassLibrary.SupplierOrder sorder = new ClassLibrary.SupplierOrder();
                sorder.OrderId = Convert.ToInt32(drOrder.ItemArray[0]);
                DataTable dt = sorder.GetSorderByOrderId().Tables[0];

                //disables forms items
                if (dt.Rows.Count != 0)
                {
                    MakeOrderUnEditable();
                    saveDeliveryDate        = true;
                    dateTimePicker1.Enabled = true;
                }

                //select the customer combobox
                string custId = drOrder.ItemArray[1].ToString();
                try
                {
                    cmbCustomers.SelectedIndex = cmbCustomers.FindStringExact(custId);
                }
                catch (Exception ex)
                {
                }
                //display date
                dateTimePicker1.Text = drOrder.ItemArray[5].ToString();

                //display total price
                totalPrice     = Convert.ToDecimal(drOrder.ItemArray[3]);
                txtPrice.Text  = String.Format("{0:c}", totalPrice);
                txtStatus.Text = drOrder.ItemArray[4].ToString();

                //display orderdetails
                ClassLibrary.CustomerOrderDetails orderdetails = new ClassLibrary.CustomerOrderDetails();
                orderdetails.OrderId = Convert.ToInt32(drOrder.ItemArray[0]);

                DataTable thisTable = orderdetails.GetOrderDetailsByOrderId().Tables[0];

                try
                {
                    foreach (DataRow row in thisTable.Rows)
                    {
                        string price = String.Format("{0:c}", Convert.ToDecimal(row.ItemArray[3]));
                        //add to generic list
                        ord.Add(new OrderDetails
                        {
                            ProductID   = Convert.ToInt32(row.ItemArray[0]),
                            ProductName = row.ItemArray[1].ToString(),
                            Quantity    = Convert.ToInt32(row.ItemArray[2]),
                            Price       = price,
                        });
                    }
                    dataGridView1.DataSource = ord;
                }
                catch (Exception ex)
                {
                }
            }
        }