Ejemplo n.º 1
0
        /// <summary>
        /// 显示数据网格控件
        /// </summary>
        public void ShowDataGird()
        {
            this.skinDataGridView1.DataSource = null;
            this.skinDataGridView1.Columns.Clear(); //清理按钮和集合


            List <Store> list = StoreDAL.FindList(new Store(), new List <string>());

            skinDataGridView1.DataSource = list;

            skinDataGridView1.Columns["storeName"].HeaderText   = "门店名";
            skinDataGridView1.Columns["storeAddr"].HeaderText   = "门店地址";
            skinDataGridView1.Columns["storeMaster"].HeaderText = "店长";

            skinDataGridView1.Columns["id"].Visible = false;

            DataGridViewButtonColumn col_Btn_alter = new DataGridViewButtonColumn();

            col_Btn_alter.Name       = "colBtn_alter";
            col_Btn_alter.HeaderText = "";
            col_Btn_alter.DefaultCellStyle.NullValue = "修改";
            skinDataGridView1.Columns.Add(col_Btn_alter);

            DataGridViewButtonColumn col_Btn_Drop = new DataGridViewButtonColumn();

            col_Btn_Drop.Name       = "colBtn_drop";
            col_Btn_Drop.HeaderText = "";
            col_Btn_Drop.DefaultCellStyle.NullValue = "删除";
            skinDataGridView1.Columns.Add(col_Btn_Drop);
        }
Ejemplo n.º 2
0
        private void SkinDataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (skinDataGridView1.Columns[e.ColumnIndex].Name == "colBtn_drop")
            {
                Store model = new Store();
                model.Id = Convert.ToInt32(skinDataGridView1.Rows[e.RowIndex].Cells["id"].Value);
                if (StoreDAL.Drop(model, new List <string>()
                {
                    "id"
                }))
                {
                    ShowDataGird(); MessageBoxEx.Show("删除成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            if (skinDataGridView1.Columns[e.ColumnIndex].Name == "colBtn_alter")
            {
                Store model = new Store();
                model.Id          = Convert.ToInt32(skinDataGridView1.Rows[e.RowIndex].Cells["id"].Value);
                model.StoreName   = skinDataGridView1.Rows[e.RowIndex].Cells["StoreName"].Value.ToString();
                model.StoreMaster = skinDataGridView1.Rows[e.RowIndex].Cells["StoreMaster"].Value.ToString();
                if (StoreDAL.AlterByPK(model, "id"))
                {
                    ShowDataGird(); MessageBoxEx.Show("修改成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        /// <summary>
        /// Gets all store.
        /// </summary>
        /// <returns>Get All Store</returns>
        public List <Store> GetAllStore()
        {
            IStoreDAL    storeDAL = new StoreDAL();
            List <Store> result   = storeDAL.GetAllStore();

            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 填满组合框
        /// </summary>
        public void FillComboBox()
        {
            List <Store> list = StoreDAL.FindList(new Store(), new List <string>());

            comboBox2.DataSource    = list;
            comboBox2.DisplayMember = "StoreName"; //设置要显示的List元素中的属性
        }
Ejemplo n.º 5
0
        private void SkinDataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (skinDataGridView1.Columns[e.ColumnIndex].Name == "colBtn_drop")
            {
                Staff model = new Staff();
                model.Id = Convert.ToInt32(skinDataGridView1.Rows[e.RowIndex].Cells["staff_id"].Value);
                if (StaffDAL.Drop(model, new List <string>()
                {
                    "id"
                }))
                {
                    ShowDataGird(); MessageBoxEx.Show("删除成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            if (skinDataGridView1.Columns[e.ColumnIndex].Name == "colBtn_alter")
            {
                Staff model = new Staff();
                model.Id        = Convert.ToInt32(skinDataGridView1.Rows[e.RowIndex].Cells["staff_id"].Value);
                model.StaffName = skinDataGridView1.Rows[e.RowIndex].Cells["staff_name"].Value.ToString();
                model.Store_Id  = Convert.ToInt32(skinDataGridView1.Rows[e.RowIndex].Cells["Store_Id"].Value);
                model.Gender    = skinDataGridView1.Rows[e.RowIndex].Cells["staff_Gender"].Value.ToString();
                if (StoreDAL.FindModel(new Store(model.Store_Id), new List <string>()
                {
                    "id"
                }) == null)
                {
                    MessageBoxEx.Show("修改失败,不存在此门店", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
                }
                if (StaffDAL.AlterByPK(model, "id"))
                {
                    ShowDataGird(); MessageBoxEx.Show("修改成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 6
0
 public List <Order> GetOrders()
 {
     try {
         StoreDAL dalobj = new StoreDAL();
         return(dalobj.ReadOrders());
     } catch {
         throw;
     }
 }
Ejemplo n.º 7
0
 public List <Customer> GetCustomers()
 {
     try {
         StoreDAL dalobj = new StoreDAL();
         return(dalobj.ReadCustomers());
     } catch {
         throw;
     }
 }
Ejemplo n.º 8
0
 public List <object[]> GetSoldToys()
 {
     try {
         StoreDAL dalobj = new StoreDAL();
         return(dalobj.ReadSoldToys());
     } catch {
         throw;
     }
 }
Ejemplo n.º 9
0
 public List <object[]> GetCustomersExpenses()
 {
     try {
         StoreDAL dalobj = new StoreDAL();
         return(dalobj.ReadCustomersExpenses());
     } catch {
         throw;
     }
 }
Ejemplo n.º 10
0
 public List <object[]> GetOrdersInfo()
 {
     try {
         StoreDAL dalobj = new StoreDAL();
         return(dalobj.ReadOrdersInfo());
     } catch {
         throw;
     }
 }
Ejemplo n.º 11
0
 public List <Toy> GetToys()
 {
     try {
         StoreDAL dalobj = new StoreDAL();
         return(dalobj.ReadToys());
     } catch {
         throw;
     }
 }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            var    s_Stores = Menu.StoreMenu(); // pick store
            var    sDAL     = new StoreDAL();   // access db about stores
            Stores store    = s_Stores;

            var custRepo  = new CustomerRepository(new DbRestaurantContext());
            var customer1 = custRepo.Get(1);


            Console.WriteLine(customer1.FullName);
            Customer customer = new Customer("default", "default", "default1231!");
        }
Ejemplo n.º 13
0
    public Store CheckStoreUserLogin(string username, string password)
    {
        Store store = new StoreDAL().CheckUserInfo(username, password);

        if (store!=null)
        {
            store.StoreName = username;
            store.StorePassword = password;
            return store;
        }
        else
        {
            return null;
        }
    }
Ejemplo n.º 14
0
        /// <summary>
        /// 点击新增门店
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAbout_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
            {
                MessageBoxEx.Show("请填写完整信息", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
            }
            Store model = new Store();

            model.StoreName   = textBox1.Text;
            model.StoreAddr   = textBox2.Text;
            model.StoreMaster = textBox3.Text;
            if (StoreDAL.Add(model))
            {
                ShowDataGird(); MessageBoxEx.Show("添加门店成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public void GetAllStore()
        {
            IStoreDAL storeDal = new StoreDAL();

            List <Store> dummy  = this.GetDummyStore();
            List <Store> actual = storeDal.GetAllStore();

            for (int i = 0; i < dummy.Count; i++)
            {
                Assert.AreEqual(dummy[i].StoreID, actual[i].StoreID);
                Assert.AreEqual(dummy[i].Name, actual[i].Name);
                Assert.AreEqual(dummy[i].SalesOrderNumber, actual[i].SalesOrderNumber);
                Assert.AreEqual(dummy[i].OrderDate, actual[i].OrderDate);
                Assert.AreEqual(dummy[i].TotalDue, actual[i].TotalDue);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 点击录入员工
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAbout_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBoxEx.Show("请填写员工姓名", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
            }
            Staff model = new Staff();

            model.StaffName = textBox1.Text;
            model.Gender    = comboBox1.Text;
            model.Store_Id  = StoreDAL.FindModel(new Store(comboBox2.Text.ToString(), null, null), new List <string>()
            {
                "StoreName"
            }).Id;
            if (StaffDAL.Add(model))
            {
                ShowDataGird(); MessageBoxEx.Show("新增员工成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 17
0
        public static Stores StoreMenu()
        {
            Console.WriteLine("Displaying all stores");

            // load all stores
            var sDAL         = new StoreDAL();
            var listOfStores = sDAL.LoadAllStores();

            foreach (var store in listOfStores)
            {
                Console.WriteLine(store.StoreId + " " + store.StoreName);
                Console.WriteLine(store.StreetAddress);
                Console.WriteLine(store.City + ", " + store.State + ", " + store.Zipcode);
            }
            Console.WriteLine("Please select a store");
            var storeIDChosen = Convert.ToInt32(Console.ReadLine());

            // load store by id to pass to other methods
            var storeChosen = sDAL.LoadStoreByID(storeIDChosen);

            return(storeChosen);
        }
Ejemplo n.º 18
0
    /// <summary>
    /// 得到用户列表
    /// </summary>
    /// <param name="PageIndex"></param>
    /// <param name="PageNum"></param>
    /// <param name="where"></param>
    /// <param name="Count"></param>
    /// <returns></returns>
    public List <AdminModel> GetAdminList(int PageIndex, int PageNum, string where, out int Count)
    {
        List <AdminModel> olist = new List <AdminModel>();

        Count = 0;
        SqlConnection sqlConnection = new SqlConnection(Config.ConnectionString);
        SqlCommand    sqlcommand    = new SqlCommand("sp_AdminList", sqlConnection);

        sqlcommand.CommandType = CommandType.StoredProcedure;

        SqlParameter _PageIndex = new SqlParameter("@PageIndex", PageIndex);

        _PageIndex.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_PageIndex);

        SqlParameter _PageNum = new SqlParameter("@PageNum", PageNum);

        _PageNum.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_PageNum);

        SqlParameter _where = new SqlParameter("@where", where);

        _where.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_where);

        SqlParameter _Count = new SqlParameter("@Count", SqlDbType.Int);

        _Count.Direction = ParameterDirection.Output;
        sqlcommand.Parameters.Add(_Count);
        try
        {
            sqlConnection.Open();
            using (IDataReader idr = sqlcommand.ExecuteReader())
            {
                DealerDAL      dd   = new DealerDAL();
                StoreDAL       sd   = new StoreDAL();
                PermissionsDAL pDal = new PermissionsDAL();
                while (idr.Read())
                {
                    AdminModel oCModel = new AdminModel();
                    if (idr["AdminId"] != DBNull.Value)
                    {
                        oCModel.AdminId = (int)idr["AdminId"];
                    }
                    if (idr["AdminName"] != DBNull.Value)
                    {
                        oCModel.AdminName = (string)idr["AdminName"];
                    }
                    if (idr["AdminPassword"] != DBNull.Value)
                    {
                        oCModel.AdminPassword = (string)idr["AdminPassword"];
                    }
                    if (idr["Type"] != DBNull.Value)
                    {
                        oCModel.Type = (AdminType)idr["Type"];
                    }
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        oCModel.RoleId = (int)idr["RoleId"];
                    }
                    if (idr["Status"] != DBNull.Value)
                    {
                        oCModel.Status = (bool)idr["Status"];
                    }
                    if (idr["CreateTime"] != DBNull.Value)
                    {
                        oCModel.CreateTime = (DateTime)idr["CreateTime"];
                    }

                    if (idr["CreatorId"] != DBNull.Value)
                    {
                        oCModel.CreatorId = (int)idr["CreatorId"];
                    }
                    int Totoal = 0;
                    List <DealerModel> dModel = dd.GetDealerModelList(1, 1, "DealerInfo.AdminId=" + oCModel.AdminId, out Totoal);
                    if (dModel != null & dModel.Count > 0)
                    {
                        oCModel.Dealer = dModel[0];
                    }
                    List <StoreModel> oSMoel = sd.GetStoreModelList(1, 1, "StoreInfo.AdminId=" + oCModel.AdminId, out Totoal);
                    if (oSMoel != null & oSMoel.Count > 0)
                    {
                        oCModel.Store = oSMoel[0];
                    }
                    RoleModel role = new RoleModel();
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        role.RoleId = (int)idr["RoleId"];
                    }
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        role.RoleName = (string)idr["RoleName"];
                    }
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        role.Permissions = pDal.GetRoleModulePermission(role.RoleId);
                    }
                    oCModel.Role = role;
                    olist.Add(oCModel);
                }
            }
            Count = int.Parse(_Count.Value.ToString());
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            sqlConnection.Close();
        }
        return(olist);
    }
Ejemplo n.º 19
0
 /// <summary>
 /// 获取所有门店信息
 /// </summary>
 /// <returns></returns>
 public List <StoreInfoEntity> GetAllStore()
 {
     return(StoreDAL.GetAllStore());
 }
Ejemplo n.º 20
0
 /// <summary>
 /// 根据主键更新门店信息
 /// </summary>
 /// <typeparam name="StoreInfoEntity"></typeparam>
 /// <param name="store"></param>
 /// <returns></returns>
 public int UpdateStore <StoreInfoEntity>(StoreInfoEntity store)
 {
     return(StoreDAL.UpdateStore(store));
 }
Ejemplo n.º 21
0
 public int InsertStore <StoreInfoEntity>(StoreInfoEntity store)
 {
     return(StoreDAL.InsertStore(store));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 获取本门店的所有导购员
 /// </summary>
 /// <param name="storeID">店铺编号</param>
 /// <returns></returns>
 public List <GuiderInfo> QueryGuiderInfoListByStoreID(int?storeID)
 {
     return(StoreDAL.QueryGuiderInfoListByStoreID(storeID));
 }
Ejemplo n.º 23
0
 /// <summary>
 /// 删除门店及关联信息
 /// </summary>
 /// <param name="storeID"></param>
 /// <returns></returns>
 public bool DeleteStoreInfoRelative(string storeID)
 {
     return(StoreDAL.DeleteStoreInfoRelative(storeID));
 }
Ejemplo n.º 24
0
 public StoreBLL()
 {
     sd = new StoreDAL();
 }
Ejemplo n.º 25
0
 public List <StoreInfoEntity> GetStoreList()
 {
     return(StoreDAL.GetStoreList());
 }
Ejemplo n.º 26
0
        static void Main(string[] args)
        {
            var    s_Stores = Menu.StoreMenu(); // pick store
            var    sDAL     = new StoreDAL();   // access db about stores
            Stores store    = s_Stores;

            Customer customer = new Customer("default", "default", "default1231!");
            bool     loggedIn;

            do
            {
                loggedIn = false;

                Menu.UserMenu(s_Stores);
                var loginOrRegisterOrSearch = Convert.ToInt32(Console.ReadLine());
                switch (loginOrRegisterOrSearch)
                {
                case 1:
                    //login
                    customer = Login();
                    loggedIn = true;

                    break;

                case 2:
                    //register
                    AddCustomerToDB();     // has prompts to get user details (name, username, password)
                    customer = Login();
                    loggedIn = true;
                    break;

                case 3:
                    // search for customers in one store
                    var listOfCustomers = GetCustomers(store);
                    Console.WriteLine($"Listing all customers for store {store.StoreId} {store.StoreName}");
                    foreach (var cust in listOfCustomers)
                    {
                        Console.WriteLine($"ID. {cust.CustomerId} {cust.FullName}");
                    }
                    Console.WriteLine();     //new line

                    break;

                case 4:
                    // search customer by name
                    Console.WriteLine("Enter a full name to search for");
                    var fullName = Console.ReadLine();
                    var cDAL     = new CustomerDAL();
                    var listOfMatchingCustomers = cDAL.LoadCustomersByName(fullName);
                    if (listOfMatchingCustomers == null)
                    {
                        Console.WriteLine("No such customer(s) found");
                        break;
                    }
                    Console.WriteLine($"All customers matching {fullName}");
                    foreach (var cust in listOfMatchingCustomers)
                    {
                        Console.WriteLine($"ID= {cust.CustomerId}. {cust.FullName}/tusername = {cust.Username}");
                    }
                    break;

                default:
                    Console.WriteLine("Error: you must choose 1 or 2 or 3 or 4");
                    break;
                }
            } while (loggedIn == false);
            // now logged in with customer object
            // place an order
            Menu.CustMenu(s_Stores, customer);
            bool quitFlag = false;

            while (quitFlag == false)
            {
                Menu.CustMenu(s_Stores, customer);

                bool GoodNumber      = false;
                var  loggedInOptions = 0;
                while (!GoodNumber)
                {
                    try
                    {
                        loggedInOptions = Convert.ToInt32(Console.ReadLine());
                        GoodNumber      = true;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("That is not a number!");
                    }
                }

                switch (loggedInOptions) // strings of numbers (to avoid exceptions when converting to switch statement condition")
                {
                case 1:
                    //login
                    Console.WriteLine("Place an order");
                    AddOrder(customer, store);

                    break;

                case 2:
                    //register
                    Console.WriteLine("Showing your order history");
                    ShowOrderHistory(customer);
                    break;

                default:
                    Console.WriteLine("Error: you must choose 1 or 2");
                    break;
                }
                Console.WriteLine("Do you wish to quit? (y/n)?");
                var input = Console.ReadLine();
                if (input.ToLower() == "y")
                {
                    quitFlag = true;
                }
            }


            //



            /*var customer = new Customer("Jonny water");*/
            /*AddOrder(customer, chosenStore);*/



            /*  Console.WriteLine("Hello World!");
             *
             * Console.WriteLine("Place a new order");
             * AddCustomerToDB();
             * Console.WriteLine("All Customers in Database");
             * DisplayAllCustomersFromDB();
             * // display all customers from database*/
        }