Example #1
0
        public bool Category_Update(decimal p_Category_Info_Id, Category_Info p_Category_Info)
        {
            try
            {
                SqlParameter[] spParameter = new SqlParameter[3];

                spParameter[0]           = new SqlParameter("@Category_Id", SqlDbType.Int);
                spParameter[0].Direction = ParameterDirection.Input;
                spParameter[0].Value     = p_Category_Info_Id;

                spParameter[1]           = new SqlParameter("@Category_Name", SqlDbType.NVarChar);
                spParameter[1].Direction = ParameterDirection.Input;
                spParameter[1].Value     = p_Category_Info.Category_Name;

                spParameter[2]           = new SqlParameter("@Note", SqlDbType.NVarChar);
                spParameter[2].Direction = ParameterDirection.Input;
                spParameter[2].Value     = p_Category_Info.Note;

                SqlHelper.ExecuteNonQuery(CommonData.ConnectionString, CommandType.StoredProcedure, "proc_Category_Update", spParameter);

                return(true);
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
                return(false);
            }
        }
Example #2
0
        string Create_Product_Code()
        {
            try
            {
                if (cboItem_Type == null)
                {
                    return("");
                }

                string             _res = "";
                Product_Controller _Product_Controller = new Product_Controller();

                Category_Info _Category_Info = (Category_Info)cboItem_Type.SelectedItem;

                string _name = CommonFunction.ConvertVN(_Category_Info.Category_Name);

                // lấy ra id hiện tại của thằng product
                decimal _max_id = _Product_Controller.Product_Get_Max_Id();

                _res = "NS_" + _name.ToUpper() + "_" + (_max_id + 1).ToString();

                return(_res);
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
                return("");
            }
        }
Example #3
0
        void Category_Delete()
        {
            try
            {
                c_row_select = dgrCategory.SelectedIndex;
                Category_Info _Category_Info = (Category_Info)dgrCategory.SelectedItem;

                if (_Category_Info == null)
                {
                    return;
                }

                MessageBoxResult result = NoteBox.Show("Bạn chắc chắn muốn xóa loại sản phẩm hay không?", "Thông báo", NoteBoxLevel.Question);
                if (MessageBoxResult.Yes == result)
                {
                    if (c_Category_Controller.Categor_Delete(_Category_Info.Category_Id))
                    {
                        NoteBox.Show("Xóa dữ liệu thành công");
                        LoadData();
                    }
                }
                else
                {
                    DataGridHelper.NVSFocus(dgrCategory, c_row_select, 0);
                }
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
            }
        }
Example #4
0
        void Category_Update()
        {
            try
            {
                c_row_select = dgrCategory.SelectedIndex;
                Category_Info _Category_Info = (Category_Info)dgrCategory.SelectedItem;

                if (_Category_Info == null)
                {
                    return;
                }
                frmCreate_Category _frmCreate_Category = new frmCreate_Category();
                _frmCreate_Category.c_type          = Convert.ToInt16(Form_Type.Update);
                _frmCreate_Category.c_Category_Info = _Category_Info;
                _frmCreate_Category.Owner           = Window.GetWindow(this);
                _frmCreate_Category.ShowDialog();

                if (_frmCreate_Category.c_id_insert != 0)
                {
                    LoadData();
                }

                DataGridHelper.NVSFocus(dgrCategory, c_row_select, 0);
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
            }
        }
Example #5
0
        void Insert_Category()
        {
            try
            {
                frmCreate_Category _frmCreate_Category = new frmCreate_Category();
                _frmCreate_Category.c_type = Convert.ToInt16(Form_Type.Insert);
                _frmCreate_Category.Owner  = Window.GetWindow(this);
                _frmCreate_Category.ShowDialog();

                if (_frmCreate_Category.c_id_insert != 0)
                {
                    LoadData();

                    for (int i = 0; i < c_lst.Count; i++)
                    {
                        Category_Info ui = (Category_Info)c_lst[i];
                        if (ui.Category_Id == _frmCreate_Category.c_id_insert)
                        {
                            c_row_select = i;
                            _frmCreate_Category.c_id_insert = 0;
                            break;
                        }
                    }
                }

                DataGridHelper.NVSFocus(dgrCategory, c_row_select, 0);
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
            }
        }
Example #6
0
        void Accept()
        {
            try
            {
                if (!CheckValidate_F())
                {
                    return;
                }
                Category_Controller _Category_Controller = new Category_Controller();

                if (c_type == Convert.ToInt16(Form_Type.Insert))
                {
                    MessageBoxResult result = NoteBox.Show("Bạn chắc chắn muốn thêm mới nhà cung cấp hay không?", "Thông báo", NoteBoxLevel.Question);
                    if (MessageBoxResult.Yes == result)
                    {
                        Category_Info _Category_Info = new Category_Info();
                        _Category_Info.Category_Name = txtName.Text;

                        decimal _id = 0;

                        if (_Category_Controller.Category_Insert(_Category_Info, ref _id))
                        {
                            NoteBox.Show("Thêm mới thành công");
                            c_id_insert = _id;
                            this.Close();
                        }
                        else
                        {
                            NoteBox.Show("Có lỗi trong quá trình thêm mới", "", NoteBoxLevel.Error);
                        }
                    }
                }
                else
                {
                    MessageBoxResult result = NoteBox.Show("Bạn chắc chắn muốn cập nhật hay không?", "Thông báo", NoteBoxLevel.Question);
                    if (MessageBoxResult.Yes == result)
                    {
                        Category_Info _Category_Info = new Category_Info();
                        _Category_Info.Category_Name = txtName.Text;

                        if (_Category_Controller.Category_Update(c_Category_Info.Category_Id, _Category_Info))
                        {
                            NoteBox.Show("Cập nhật dữ liệu thành công");
                            c_id_insert = 1;
                            this.Close();
                        }
                        else
                        {
                            NoteBox.Show("Có lỗi trong quá trình cập nhật dữ liệu", "", NoteBoxLevel.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
            }
        }
Example #7
0
 private void ListSetting()
 {
     for (int i = 0; i < 3; i++)
     {
         Category_Info ci       = new Category_Info();
         double[]      ctAmount = new double[9];
         double[]      ctPrice  = new double[9];
         ci.count_table = ctAmount;
         ci.price_table = ctPrice;
         CategoryData.Add(ci);
     }
 }
Example #8
0
        private void GetValues()
        {//10.80.162.193
            string connStr = "Server=10.80.162.193;Database=mcdonald_kiosk;Uid=root;Pwd=kmk5632980;";

            using (MySqlConnection conn = new MySqlConnection(connStr))
            {
                conn.Open();
                string sql = "SELECT * FROM menu";

                MySqlCommand    cmd = new MySqlCommand(sql, conn);
                MySqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    Menu_Info menu = new Menu_Info();
                    menu.name        = rdr["menu_name"].ToString();
                    menu.category    = rdr["category"].ToString();
                    menu.price       = double.Parse(rdr["price"].ToString());
                    menu.count_table = new double[9];
                    menu.price_table = new double[9];
                    MenuData.Add(menu);
                }
                rdr.Close();
            }

            using (MySqlConnection conn = new MySqlConnection(connStr))
            {
                conn.Open();
                string sql = "SELECT * FROM ordered_menu";

                MySqlCommand    cmd = new MySqlCommand(sql, conn);
                MySqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    double[] countArr = new double[9];
                    double[] priceArr = new double[9];
                    int      menu_idx = int.Parse(rdr["menu_idx"].ToString()) - 1;
                    int      tableNum = int.Parse(rdr["tableNum"].ToString()) - 1;

                    Menu_Info tempMenu = new Menu_Info();
                    tempMenu.name        = MenuData[menu_idx].name;
                    tempMenu.category    = MenuData[menu_idx].category;
                    tempMenu.price       = MenuData[menu_idx].price;
                    tempMenu.total_count = MenuData[menu_idx].total_count + double.Parse(rdr["amount"].ToString());
                    tempMenu.total_price = tempMenu.total_count * MenuData[menu_idx].price;

                    if (MenuData[menu_idx].count_table != null)
                    {
                        countArr = MenuData[menu_idx].count_table;
                        priceArr = MenuData[menu_idx].price_table;
                    }

                    if (tableNum >= 0)
                    {
                        countArr[tableNum]  += int.Parse(rdr["amount"].ToString());
                        priceArr[tableNum]   = countArr[tableNum] * tempMenu.price;
                        tempMenu.count_table = countArr;
                        tempMenu.price_table = priceArr;
                    }
                    else
                    {
                        tempMenu.count_table = countArr;
                        tempMenu.price_table = priceArr;
                    }
                    MenuData[menu_idx] = tempMenu;

                    Category_Info category = new Category_Info();
                    double[]      ctAmount = new double[9];
                    double[]      ctPrice  = new double[9];

                    if (tableNum >= 0)
                    {
                        ctAmount             = CategoryData[GetTypeOfCategory(tempMenu.category)].count_table;
                        ctPrice              = CategoryData[GetTypeOfCategory(tempMenu.category)].price_table;
                        ctAmount[tableNum]  += double.Parse(rdr["amount"].ToString());
                        ctPrice[tableNum]    = ctAmount[tableNum] * tempMenu.price;
                        category.count_table = ctAmount;
                        category.price_table = ctPrice;
                        CategoryData[GetTypeOfCategory(tempMenu.category)] = category;
                    }
                }

                foreach (Menu_Info menu in MenuData)
                {
                    int categoryType = GetTypeOfCategory(menu.category);

                    Category_Info category = new Category_Info();
                    category.name              = menu.category;
                    category.total_count       = menu.total_count + CategoryData[categoryType].total_count;
                    category.total_price       = menu.total_price + CategoryData[categoryType].total_price;
                    category.count_table       = CategoryData[categoryType].count_table;
                    category.price_table       = CategoryData[categoryType].price_table;
                    CategoryData[categoryType] = category;
                }
                rdr.Close();
            }
        }