Exemple #1
0
        private void Method()
        {
            session1DataSetTableAdapters.UsersTableAdapter adapter = new session1DataSetTableAdapters.UsersTableAdapter();
            var officeData = adapter.GetData();
            var s          = (from i in officeData
                              select i);
            string str = "";

            foreach (var i in s)
            {
                str += i.Password + "  ";
            }
            MessageBox.Show(str);
        }
Exemple #2
0
        public static void Parser(string path)
        {
            var allLines = File.ReadLines(path);

            foreach (var item in allLines)
            {
                var arrValue = item.Split(',');
                if (arrValue.Length == 8)
                {
                    User user = new User();

                    user.RoleID   = arrValue[0] == "Administrator" ? 1 : 2;
                    user.Email    = arrValue[1];
                    user.Password = GetMd5Hash(arrValue[2]);
                    //user.Password = arrValue[2];
                    user.FirstName = arrValue[3];
                    user.LastName  = arrValue[4];

                    session1DataSetTableAdapters.OfficesTableAdapter adapter = new session1DataSetTableAdapters.OfficesTableAdapter();
                    var officeData = adapter.GetData();
                    int id         = (from i in officeData
                                      where i.Title == arrValue[5]
                                      select i.ID).First();

                    user.OfficeID  = id;
                    user.Birthdate = DateTime.ParseExact(arrValue[6], "MM/dd/yyyy", CultureInfo.InvariantCulture);
                    user.Active    = arrValue[7] == "1" ? true : false;

                    session1DataSetTableAdapters.UsersTableAdapter adapterUser = new session1DataSetTableAdapters.UsersTableAdapter();

                    var userData = adapterUser.GetData();
                    int UserID   = 0;
                    try
                    {
                        UserID = (from i in userData
                                  orderby i.ID descending
                                  select i.ID).First() + 1;
                    }
                    catch { }

                    adapterUser.Insert(UserID, user.RoleID, user.Email, user.Password, user.FirstName, user.LastName, user.OfficeID, user.Birthdate, user.Active);
                }
                else
                {
                    throw new Exception("CSVParser::Parser::invalidqtyparam");
                }
            }
        }