Exemplo n.º 1
0
        public static void DataUpdate(int UserToDataUpdate)
        {
            string[] Names = Directory.GetFileSystemEntries(Class_Data.GeneralPathToSave + UserToDataUpdate);
            foreach (string NameP in Names)
            {
                int    NameBegin = NameP.LastIndexOf(@"\");
                string Name      = "";
                for (int g = NameBegin + 1; g < NameP.LastIndexOf("") + 1; g++)
                {
                    Name = Name + NameP[g];
                }

                int    OuterIdIntLocation = Name.LastIndexOf("_");
                string OuterIDString      = Name.Substring(0, OuterIdIntLocation);
                int    OuterID            = int.Parse(OuterIDString);
                //int InnerIDIntLocation = Name.LastIndexOf(".");
                Name = "";
                for (int g = NameP.LastIndexOf("_") + 1; g < NameP.LastIndexOf("."); g++)
                {
                    Name = Name + NameP[g];
                }

                int  InnerID        = int.Parse(Name.Substring(0, Name.Length));
                int  Location       = UserToDataUpdate;
                Data TempDataToSave = new Data(OuterID, InnerID, Location);
                Class_Data.DataList.Add(TempDataToSave);
            }
        }
        public override bool Collect(AbstractDataCollector <TEntity> collector)
        {
            if (collector == null)
            {
                return(false);
            }

            ActiveCollector = collector;

            ID = ((IUserGroupViewer)ActiveCollector.ActiveViewer).ID;

            if (ActiveDBItem == null)
            {
                return(false);
            }

            if (NameP != null)
            {
                ((UserGroup_cu)ActiveDBItem).Name_P = NameP.ToString();
            }

            if (NameS != null)
            {
                ((UserGroup_cu)ActiveDBItem).Name_S = NameS.ToString();
            }

            if (InternalCode != null)
            {
                ((UserGroup_cu)ActiveDBItem).InternalCode = InternalCode.ToString();
            }

            if (Description != null)
            {
                ((UserGroup_cu)ActiveDBItem).Description = Description.ToString();
            }

            if (UserID != null)
            {
                ((UserGroup_cu)ActiveDBItem).InsertedBy = Convert.ToInt32(UserID);
            }

            ((UserGroup_cu)ActiveDBItem).IsOnDuty = true;
            switch (((IUserGroupViewer)ActiveCollector.ActiveViewer).CommonTransactionType)
            {
            case DB_CommonTransactionType.DeleteExisting:
                ((UserGroup_cu)ActiveDBItem).IsOnDuty = false;
                break;
            }

            RelatedViewers = ((IUserGroupViewer)ActiveCollector.ActiveViewer).RelatedViewers;

            return(true);
        }
Exemplo n.º 3
0
        private void ToSignIn()
        {
            SqlConnection con = null;
            SqlCommand    com;
            SqlDataReader reader = null;


            try {
                con = new SqlConnection(connectionString);
                string encPassword = GetEncodingPassword(Password.Text);
                con.Open();
                com = new SqlCommand("Select Count(*) From Users Where Name = @Name and Password = @Password", con);
                com.Parameters.AddWithValue("@Name", NameP.Text);
                com.Parameters.AddWithValue("@Password", encPassword);
                int  count    = (int)com.ExecuteScalar();
                byte countTry = 1;

                if (count == 0)
                {
                    MessageBox.Show("Введеные неверные данные");
                    NameP.Clear();
                    Password.Clear();
                    countTry++;
                    return;
                }
                else
                {
                    MessageBox.Show("Вход выполнен");
                    ToWriteFile();

                    com = new SqlCommand("Select ID, Rights From Users Where Name = @Name and Password = @Password", con);
                    com.Parameters.AddWithValue("@Name", NameP.Text);
                    com.Parameters.AddWithValue("@Password", encPassword);
                    reader = com.ExecuteReader();
                    reader.Read();

                    object rights = reader.GetString(1);
                    id = reader.GetValue(0);
                    EditForm(rights);
                    ToWriteDataBaseSuccessful(countTry);
                    reader.Close();
                }

                if (countTry == 3)
                {
                    ToWriteDataBaseNotSuccessful(countTry);
                    MessageBox.Show("Мсье, вы не знаете пароля");
                    Application.Exit();
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
            finally { con.Close(); }
        }
Exemplo n.º 4
0
        private void ToWriteFile()
        {
            FileStream   stream = null;
            StreamWriter write  = null;

            try {
                stream = new FileStream("date.txt", FileMode.Truncate);
                write  = new StreamWriter(stream, System.Text.Encoding.Default);

                if (!RememberMe.Checked)
                {
                    write.Write("");
                    NameP.Clear();
                    Password.Clear();
                }
                else
                {
                    byte[] nameByte = System.Text.Encoding.Default.GetBytes(NameP.Text);
                    string strName  = "";
                    for (int i = 0; i < nameByte.Length; i++)
                    {
                        if (i == nameByte.Length - 1)
                        {
                            strName += nameByte[i].ToString();
                        }
                        else
                        {
                            strName += nameByte[i].ToString() + ",";
                        }
                    }

                    byte[] pasByte = System.Text.Encoding.Default.GetBytes(Password.Text);
                    string strPas  = "";
                    for (int i = 0; i < pasByte.Length; i++)
                    {
                        if (i == pasByte.Length - 1)
                        {
                            strPas += pasByte[i].ToString();
                        }
                        else
                        {
                            strPas += pasByte[i].ToString() + ",";
                        }
                    }

                    write.WriteLine(strName);
                    write.WriteLine(strPas);
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
            finally { write.Close(); stream.Close(); }
        }
        public override bool Collect(AbstractDataCollector <TEntity> collector)
        {
            if (collector == null)
            {
                return(false);
            }

            ActiveCollector = collector;

            ID = ((IServiceCategoryViewer)ActiveCollector.ActiveViewer).ID;

            if (ActiveDBItem == null)
            {
                return(false);
            }

            if (NameP != null)
            {
                ((ServiceCategory_cu)ActiveDBItem).Name_P = NameP.ToString();
            }

            if (NameS != null)
            {
                ((ServiceCategory_cu)ActiveDBItem).Name_S = NameS.ToString();
            }

            if (InternalCode != null)
            {
                ((ServiceCategory_cu)ActiveDBItem).InternalCode = InternalCode.ToString();
            }

            if (ServiceType != null)
            {
                ((ServiceCategory_cu)ActiveDBItem).ServiceType_P_ID = Convert.ToInt32(ServiceType);
            }

            ((ServiceCategory_cu)ActiveDBItem).IsMedical = Convert.ToBoolean(IsMedical);

            ((ServiceCategory_cu)ActiveDBItem).AllowAdmission = Convert.ToBoolean(AlloAdmission);

            if (Description != null)
            {
                ((ServiceCategory_cu)ActiveDBItem).Description = Description.ToString();
            }

            if (UserID != null)
            {
                ((ServiceCategory_cu)ActiveDBItem).InsertedBy = Convert.ToInt32(UserID);
            }

            ((ServiceCategory_cu)ActiveDBItem).IsOnDuty = true;
            switch (((IServiceCategoryViewer)ActiveCollector.ActiveViewer).CommonTransactionType)
            {
            case DB_CommonTransactionType.DeleteExisting:
                ((ServiceCategory_cu)ActiveDBItem).IsOnDuty = false;
                break;
            }

            RelatedViewers = ((IServiceCategoryViewer)ActiveCollector.ActiveViewer).RelatedViewers;

            return(true);
        }
Exemplo n.º 6
0
 public void ClearTextBox()
 {
     NameP.Clear();
     Password.Clear();
     RememberMe.Checked = false;
 }