Example #1
0
        private void btnThem_Click_1(object sender, EventArgs e)
        {
            ComboBLL comboBLL = new ComboBLL();
            Combo    combo    = new Combo();

            try
            {
                if (flagimage)
                {
                    fullpath = DBConnection.folder_combo + path;
                }
                int i = 1;
                while (File.Exists(DBConnection.folder_combo + path))
                {
                    if (path.Contains("(") && path.Contains(")"))
                    {
                        string[] f   = path.Split('(');
                        string[] n   = f[1].Split(')');
                        int      num = int.Parse(n[0]);
                        path = path.Replace("(" + num + ")", "(" + ++num + ")");
                    }
                    else
                    {
                        string[] t = path.Split('.');
                        path = t[0] + "(" + i + ")." + t[1];
                    }
                }
                File.Copy(fullpath, DBConnection.folder_combo + path);
                flagimage = false;

                combo.comboName     = txtComboName.Text;
                combo.dayStart      = dayStart.Value;
                combo.dayEnd        = dayEnd.Value;
                combo.discountMoney = numDiscount.Value.ToString();
                combo.total         = total;

                /*Lấy Tên Ảnh đưa vào cơ sở dữ liệu*/
                combo.image = path;
                comboBLL.AddCombo(combo);
                ComboProduct comboProduct = new ComboProduct();
                foreach (int listidprouct in list)
                {
                    comboProduct.product_id = int.Parse(listidprouct.ToString());
                    comboBLL.AddComboProduct(comboProduct);
                }
                LoadListView();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            ComboBLL comboBLL = new ComboBLL();
            Combo    combo    = new Combo();

            try
            {
                if (flagimage)
                {
                    fullpath = DBConnection.folder_combo + path;
                }
                int i = 1;
                while (File.Exists(DBConnection.folder_combo + path))
                {
                    string[] temp = path.Split('.');
                    path = temp[0] + "-" + i + "." + temp[1];
                    i++;
                }
                File.Copy(fullpath, DBConnection.folder_combo + path);
                flagimage = false;

                combo.comboName     = txtComboName.Text;
                combo.dayStart      = dayStart.Value;
                combo.dayEnd        = dayEnd.Value;
                combo.discountMoney = numDiscount.Value.ToString();
                combo.total         = total;

                /*Lấy Tên Ảnh đưa vào cơ sở dữ liệu*/
                combo.image = path;
                comboBLL.AddCombo(combo);
                ComboProduct comboProduct = new ComboProduct();
                foreach (int listidprouct in list)
                {
                    comboProduct.product_id = int.Parse(listidprouct.ToString());
                    comboBLL.AddComboProduct(comboProduct);
                }
                LoadListView();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #3
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            ComboBLL comboBLL = new ComboBLL();
            Combo    combo    = new Combo();

            try
            {
                if (flagimage && !File.Exists(DBConnection.folder_combo + path))
                {
                    File.Copy(fullpath, DBConnection.folder_combo + path);
                }
                flagimage = false;

                combo.comboName     = txtComboName.Text;
                combo.dayStart      = dayStart.Value;
                combo.dayEnd        = dayEnd.Value;
                combo.discountMoney = numDiscount.Value.ToString();
                combo.total         = total;

                /*Lấy Tên Ảnh đưa vào cơ sở dữ liệu*/
                combo.image = path;
                comboBLL.AddCombo(combo);
                ComboProduct comboProduct = new ComboProduct();
                foreach (int listidprouct in list)
                {
                    comboProduct.product_id = int.Parse(listidprouct.ToString());
                    comboBLL.AddComboProduct(comboProduct);
                }
                MessageBox.Show("Thêm Combo thành công", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadListView();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }