Пример #1
0
        public static BusinessLogic.Customer GetCustomerByLoginAndPassword(string Login, string Password)
        {
            AppDataSet AppData = new AppDataSet();

            AppData.ReadXml(DataPath);

            List <BusinessLogic.CustomerType> Types = new List <BusinessLogic.CustomerType>();

            for (int i = 0; i < AppData.Table_CustomerType.Rows.Count; ++i)
            {
                BusinessLogic.CustomerType CurrentType = new BusinessLogic.CustomerType();
                CurrentType.Id   = Convert.ToInt32(AppData.Table_CustomerType.Rows[i]["CustomerTypeId"]);
                CurrentType.Name = AppData.Table_CustomerType.Rows[i]["CustomerTypeName"].ToString();
                Types.Add(CurrentType);
            }

            DataRow[] ResultRows = AppData.Table_Customers.Select("CustomerLogin='******' AND CustomerPassword='******'");
            if (ResultRows.Length == 0)
            {
                AppData.Dispose();
                return(null);
            }

            BusinessLogic.Customer Result = new BusinessLogic.Customer();
            Result.Id          = Convert.ToInt32(ResultRows[0]["CustomerId"]);
            Result.Login       = Login;
            Result.Password    = Password;
            Result.CurrentType = Types.Find(temp => temp.Id == Convert.ToInt32(ResultRows[0]["CustomerTypeId"]));
            AppData.Dispose();
            return(Result);
        }
Пример #2
0
        public static List <BusinessLogic.Customer> GetCustomersList()
        {
            List <BusinessLogic.Customer> Result = new List <BusinessLogic.Customer>();
            AppDataSet AppData = new AppDataSet();

            AppData.ReadXml(DataPath);

            List <BusinessLogic.CustomerType> Types = new List <BusinessLogic.CustomerType>();

            for (int i = 0; i < AppData.Table_CustomerType.Rows.Count; ++i)
            {
                BusinessLogic.CustomerType CurrentType = new BusinessLogic.CustomerType();
                CurrentType.Id   = Convert.ToInt32(AppData.Table_CustomerType.Rows[i]["CustomerTypeId"]);
                CurrentType.Name = AppData.Table_CustomerType.Rows[i]["CustomerTypeName"].ToString();
                Types.Add(CurrentType);
            }

            for (int i = 0; i < AppData.Table_Customers.Rows.Count; ++i)
            {
                BusinessLogic.Customer NewCustomer = new BusinessLogic.Customer();
                NewCustomer.Id          = Convert.ToInt32(AppData.Table_Customers.Rows[i]["CustomerId"]);
                NewCustomer.Login       = AppData.Table_Customers.Rows[i]["CustomerLogin"].ToString();
                NewCustomer.Password    = AppData.Table_Customers.Rows[i]["CustomerPassword"].ToString();
                NewCustomer.CurrentType = Types.Find(temp => temp.Id == Convert.ToInt32(AppData.Table_Customers.Rows[i]["CustomerTypeId"]));
                Result.Add(NewCustomer);
            }
            return(Result);
        }
Пример #3
0
        public static List <BusinessLogic.CustomerType> GetCustomerTypeList()
        {
            AppDataSet AppData = new AppDataSet();

            AppData.ReadXml(DataPath);
            List <BusinessLogic.CustomerType> Result = new List <BusinessLogic.CustomerType>();

            for (int i = 0; i < AppData.Table_CustomerType.Rows.Count; ++i)
            {
                BusinessLogic.CustomerType CurrentType = new BusinessLogic.CustomerType();
                CurrentType.Id   = Convert.ToInt32(AppData.Table_CustomerType.Rows[i]["CustomerTypeId"]);
                CurrentType.Name = AppData.Table_CustomerType.Rows[i]["CustomerTypeName"].ToString();
                Result.Add(CurrentType);
            }
            AppData.Dispose();
            return(Result);
        }