Exemple #1
0
        // add staff button
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                // selcted item name
                var name = ValidateClass.CheckEmptyString(comboBox1.SelectedItem.ToString());

                // selected item name
                var id        = Getquery.GetDepartmentId(name);
                var firstName = ValidateClass.CheckEmptyString(textBox1.Text);
                var lastName  = ValidateClass.CheckEmptyString(textBox2.Text);
                var telPhone  = int.Parse(ValidateClass.CheckEmptyString(textBox4.Text));
                var email     = ValidateClass.CheckEmptyString(textBox6.Text);
                var salary    = int.Parse(textBox5.Text);
                //todays date
                DateTime dateTime = DateTime.UtcNow;
                var      hireDate = dateTime.ToString("dd/MM/yyyy");
                DateTime date     = DateTime.Parse(hireDate);
                // add employee
                Getquery.AddEmployee(firstName, lastName, email, telPhone, date, salary, id);
                MessageBox.Show("New employee Added");
                // empty textbox
                textBox1.Text = "";
                textBox2.Text = "";
                textBox4.Text = "";
                textBox5.Text = "";
                textBox6.Text = "";
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid Operation");
            }
        }
Exemple #2
0
            public TV Search(TK key)
            {
                // Создаем экземпляр класса валидации.
                var validate = new ValidateClass <TK, TV>();

                validate.ValidateKey(key);

                validate.ValidateKeySize(key);

                var hash = GetHash(key);

                if (!_hashMapItems.ContainsKey(hash))
                {
                    throw new KeyNotFoundException($"There is no such key: {nameof(key)}");
                }

                var oldHashTableItem = _hashMapItems[hash];

                if (oldHashTableItem != null)
                {
                    var item = oldHashTableItem.SingleOrDefault(obj =>
                                                                EqualityComparer <TK> .Default.Equals(obj.Key, key));

                    if (item != null)
                    {
                        return(item.Value);
                    }
                }

                // Возвращаем пустое значение.
                return(default(TV));
            }
        private void button1_Click(object sender, EventArgs e)
        {
            var deptName = ValidateClass.CheckEmptyString(textBox1.Text);

            processQuery.UpdatDepartment(DeptClass.DepartmentId, deptName);
            MessageBox.Show("Department Updated ");
        }
Exemple #4
0
            // Метод удаления по ключу.
            public void Delete(TK key)
            {
                // Создаем экземпляр класса валидации.
                var validate = new ValidateClass <TK, TV>();

                // Проверяем наличие ключа.
                validate.ValidateKey(key);

                // Проверяем размер ключа.
                validate.ValidateKeySize(key);

                var hash = GetHash(key);

                if (!_hashMapItems.ContainsKey(hash))
                {
                    throw new KeyNotFoundException($"There is no such key: {nameof(key)}");
                }

                var oldHashTableItem = _hashMapItems[hash];

                var item = oldHashTableItem.SingleOrDefault(obj => EqualityComparer <TK> .Default.Equals(obj.Key, key));

                // Если элемент найден - удаляем.
                if (item != null)
                {
                    oldHashTableItem.Remove(item);
                }
            }
Exemple #5
0
        // update button

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                // selected department name
                var name      = comboBox1.SelectedItem.ToString();
                var id        = Getprocess.GetDepartmentId(name);
                var firstName = ValidateClass.CheckEmptyString(textBox1.Text);
                var lastName  = ValidateClass.CheckEmptyString(textBox2.Text);
                var telPhone  = int.Parse(ValidateClass.CheckEmptyString(textBox5.Text));
                var email     = ValidateClass.CheckEmptyString(textBox3.Text);
                var salary    = int.Parse(textBox4.Text);
                // todays date
                DateTime dateTime = DateTime.UtcNow;
                var      hireDate = dateTime.ToString("dd/MM/yyyy");
                DateTime date     = DateTime.Parse(hireDate);
                // update employee
                Getprocess.EmployeeUpdate(firstName, lastName, email, telPhone, date, salary, id, EmployeId);
                MessageBox.Show("Employee Edited");
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid operation ");
            }
        }
        // add department button
        private void button1_Click(object sender, EventArgs e)
        {
            var textValue = ValidateClass.CheckEmptyString(textBox1.Text);

            Getquery.AddDepartment(textValue);
            MessageBox.Show("Department Added");
            textBox1.Text = "";
        }
Exemple #7
0
            // Создание нового значения.
            public HashMapItem(TK key, TV value)
            {
                var validateClass = new ValidateClass <TK, TV>();

                validateClass.ValidateEntryParams(key, value);

                Key   = key;
                Value = value;
            }
Exemple #8
0
            public int GetHash(TK key)
            {
                // Создаем экземпляр класса валидации.
                var validate = new ValidateClass <TK, TV>();

                validate.ValidateKey(key);

                validate.ValidateKeySize(key);

                return(key.ToString().Length);
            }
Exemple #9
0
        /// <summary>
        /// 信息记录中对应数据段的值类型校验
        /// </summary>
        /// yaoy    16.09.23
        /// <param name="informationInfo"></param>
        /// <returns></returns>
        public bool ValuesValidate()
        {
            List <ValidateClass> validateList    = new List <ValidateClass>();
            List <string>        segmentRulesIds = new List <string>();

            // metaCode数组
            int[] str = new int[] { 5101, 5107, 5109 };

            foreach (var item in str)
            {
                var segmentRulesInfo = new SegmentRules().GetSegmentRulesByInfoTypeIdAndMetaCodeAndCode(infoTypeID, item, "E");

                segmentRulesIds.Add("E" + segmentRulesInfo.SegmentRulesId.ToString());
            }

            List <Dictionary <string, string> > list = validateUtil.GetList(data, "E");

            if (list.Count > 1)
            {
                foreach (var item in list)
                {
                    ValidateClass vc = new ValidateClass();

                    var temp = item.Where(m => segmentRulesIds.Contains(m.Key)).ToArray();

                    vc.first  = temp[0].Value;
                    vc.second = temp[1].Value;
                    vc.third  = temp[2].Value;

                    validateList.Add(vc);
                }
            }

            if (validateList.Count > 0)
            {
                for (int i = 0; i < validateList.Count; i++)
                {
                    for (int j = i + 1; j < validateList.Count; j++)
                    {
                        if (validateList[i].first == validateList[j].first &&
                            validateList[i].second == validateList[j].second &&
                            validateList[i].third == validateList[j].third)
                        {
                            throw new ApplicationException("任意两个担保信息段的姓名、证件类型、证件号码不能完全相同");
                        }
                    }
                }
            }

            return(true);
        }
Exemple #10
0
            // Метод добавления новых значений в хеш-таблицу.
            // Элементы с уникальным хешем(длиной строки) добавляем новым элементом в общий словарь.
            // Элементы с уникальным ключом, но не уникальным хешем добавляем в существующий элемент словаря.
            public void Insert(TK key, TV value)
            {
                // Создаем экземпляр класса валидации.
                var validate = new ValidateClass <TK, TV>();

                validate.ValidateEntryParams(key, value);

                // Проверяем длину ключа.
                validate.ValidateKeySize(key);

                // Создаём новый элемент.
                var newHashMapItem = new HashMapItem <TK, TV>(key, value);

                // Создаём новых хеш ключа.
                var newHashMapItemHash = GetHash(key);

                List <HashMapItem <TK, TV> > newHashMapItemList = new List <HashMapItem <TK, TV> >();

                if (_hashMapItems.ContainsKey(newHashMapItemHash))
                {
                    // Находим старый элемент с существующим хешем.
                    newHashMapItemList = _hashMapItems[newHashMapItemHash]?.ToList();

                    // Пытаемся найти старый элемент с существующим ключом.
                    var oldItemWithTheSameKey =
                        newHashMapItemList.SingleOrDefault(obj => EqualityComparer <TK> .Default.Equals(obj.Key, key));

                    // Если такой ключ уже существует, то выбрасываем ошибку и не добавляем значение.
                    if (oldItemWithTheSameKey != null)
                    {
                        throw new ArgumentException(
                                  $"Хеш-таблица уже содержит элемент с ключом {key}. Ключ должен быть уникален.",
                                  nameof(key));
                    }

                    // Добавляем в существующий элемент словаря новое значение с уникальным ключом.
                    _hashMapItems[newHashMapItemHash].Add(newHashMapItem);
                }
                else
                {
                    // Создаем новый элемент словаря с уникальным ключом.
                    newHashMapItemList = new List <HashMapItem <TK, TV> > {
                        newHashMapItem
                    };
                    _hashMapItems.Add(newHashMapItemHash, newHashMapItemList);
                }
            }
Exemple #11
0
        public ActionResult Index(ValidateClass vc)
        {
            string        mainconn = ConfigurationManager.ConnectionStrings["Cnstr"].ConnectionString;
            SqlConnection sqlconn  = new SqlConnection(mainconn);
            string        sqlquery = "Insert into [dbo].[UserReg] ([UserName],[Age],[Email],[UserPassword],[UserRePassword]) values (@UserName,@Age,@Email,@UserPassword,@UserRePassword)";
            SqlCommand    sqlcomm  = new SqlCommand(sqlquery, sqlconn);

            sqlconn.Open();
            sqlcomm.Parameters.AddWithValue("@UserName", vc.Username);
            sqlcomm.Parameters.AddWithValue("@Age", vc.Age);
            sqlcomm.Parameters.AddWithValue("@Email", vc.Email);
            sqlcomm.Parameters.AddWithValue("@UserPassword", vc.Password);
            sqlcomm.Parameters.AddWithValue("@UserRePassword", vc.RePassword);

            sqlcomm.ExecuteNonQuery();
            ViewData["Message"] = "Registered Successfully, Please Login!";
            sqlconn.Close();

            return(View());
        }
Exemple #12
0
        public bool TestScripts(string text)
        {
            //Allow dummy statement?
            if (false /*string.IsNullOrEmpty(txtScript.Text)*/)
            {
                RadMessageBox.Show("Não é possível gerar estratégia em branco ou nula.", "Error:",
                                   MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                return(false);
            }
            Validate script = new ValidateClass {
                License = "XRT93NQR79ABTW788XR48"
            };

            string err = script.Validate(text);

            if (!string.IsNullOrEmpty(err))
            {
                //tabScripts.SelectedIndex = 0;
                if (script.ScriptHelp != "")
                {
                    if (RadMessageBox.Show("Sua estratégia contém um ou mais erros:\r\n" + err.Replace("Error: ", "") +
                                           "\r\nDeseja consultar uma ajuda sobre este erro?", "Error:", MessageBoxButtons.YesNo,
                                           RadMessageIcon.Exclamation) == DialogResult.Yes)
                    {
                        RadMessageBox.Show(script.ScriptHelp, "Help", MessageBoxButtons.OK, RadMessageIcon.Info);
                    }
                }
                else
                {
                    RadMessageBox.Show("Sua estratégia contém um ou mais erros:\r\n" + err.Replace("Error: ", ""), "Error:",
                                       MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                }
                return(false);
            }
            return(true);
        }
Exemple #13
0
        //Checks the scripts for errors
        private bool TestScripts()
        {
            Validate script = new ValidateClass {
                License = "XRT93NQR79ABTW788XR48"
            };
            string err = script.Validate(txtBuyScript);

            if (!string.IsNullOrEmpty(err))
            {
                if (script.ScriptHelp != "")
                {
                    if (MessageBox.Show("Your buy script generated an error:\r\n" + err.Replace("Error: ", "") +
                                        "\r\nWould you like to view help regarding this error?", "Error:", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        MessageBox.Show(script.ScriptHelp, "Help", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Your buy script generated an error:\r\n" + err.Replace("Error: ", ""), "Error:",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                return(false);
            }
            err = script.Validate(txtSellScript);
            if (!string.IsNullOrEmpty(err))
            {
                if (script.ScriptHelp != "")
                {
                    if (MessageBox.Show("Your sell script generated an error:\r\n" + err.Replace("Error: ", "") +
                                        "\r\nWould you like to view help regarding this error?", "Error:", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        MessageBox.Show(script.ScriptHelp, "Help", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Your sell script generated an error:\r\n" + err.Replace("Error: ", ""), "Error:",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                return(false);
            }
            err = script.Validate(txtExitLongScript);
            if (!string.IsNullOrEmpty(err))
            {
                if (script.ScriptHelp != "")
                {
                    if (MessageBox.Show("Your exit long script generated an error:\r\n" + err.Replace("Error: ", "") +
                                        "\r\nWould you like to view help regarding this error?", "Error:", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        MessageBox.Show(script.ScriptHelp, "Help", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Your exit-long script generated an error:\r\n" + err.Replace("Error: ", ""), "Error:",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                return(false);
            }
            err = script.Validate(txtExitShortScript);
            if (!string.IsNullOrEmpty(err))
            {
                if (script.ScriptHelp != "")
                {
                    if (MessageBox.Show("Your exit short script generated an error:\r\n" + err.Replace("Error: ", "") +
                                        "\r\nWould you like to view help regarding this error?", "Error:", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        MessageBox.Show(script.ScriptHelp, "Help", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Your exit-short script generated an error:\r\n" + err.Replace("Error: ", ""), "Error:",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                return(false);
            }
            return(true);
        }