コード例 #1
0
ファイル: Model.cs プロジェクト: tsdeveloper/mShop-1
 public void CloseConnection()
 {
     if (db != null)
     {
         db = null;
     }
 }
コード例 #2
0
ファイル: Model.cs プロジェクト: tsdeveloper/mShop-1
 private int?GetUserShopId(string login)
 {
     using (var db = new mshopEntities(loginuser, loginpassword))
     {
         try
         {
             var user   = db.Users.Where(item => item.Login == login).ToList();
             int?shopId = user[0].S_Id;
             return(shopId);
         }
         catch (Exception e)
         {
             throw new NotImplementedException();
         }
     }
 }
コード例 #3
0
ファイル: Model.cs プロジェクト: tsdeveloper/mShop-1
 public string GetWorkingPlaceOfUser(string login)
 {
     using (var db = new mshopEntities(loginuser, loginpassword))
     {
         try
         {
             string query = "CALL work_place('" + login + "');";
             string s     = db.Database.SqlQuery <string>(query).ToString();
             return(s);
         }
         catch
         {
             return(null);
         }
     }
 }
コード例 #4
0
ファイル: Model.cs プロジェクト: tsdeveloper/mShop-1
 public bool UserExists(string username, string password)
 {
     using (var db = new mshopEntities(username, password))
     {
         try
         {
             db.SetCommandTimeOut(1);
             db.Database.Connection.Open();
             return(true);
         }
         catch
         {
             return(false);
         }
         finally
         {
             db.SetCommandTimeOut(100);
         }
     }
 }
コード例 #5
0
ファイル: Model.cs プロジェクト: tsdeveloper/mShop-1
        public bool OpenConnection(ConnectionType connectionType)
        {
            try
            {
                db = new mshopEntities(Login, Password);
                db.Database.Connection.Open();

                if (connectionType == ConnectionType.Shop)
                {
                    ShopModel = new ShopModel(db, GetUserShopId(Login));
                }
                else if (connectionType == ConnectionType.Warehouse)
                {
                    WarehouseModel = new WarehouseModel(db, GetUserWarehouseId(Login));
                }

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
コード例 #6
0
ファイル: ShopModel.cs プロジェクト: tsdeveloper/mShop-1
 public ShopModel(mshopEntities database, int?cS)
 {
     db          = database;
     currentShop = cS;
 }
コード例 #7
0
ファイル: WarehouseModel.cs プロジェクト: tsdeveloper/mShop-1
 public WarehouseModel(mshopEntities database, int?cW)
 {
     db = database;
     currentWarehouse = cW;
 }