コード例 #1
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            DAL.DataAccess da = new DAL.DataAccess();

            if (String.IsNullOrEmpty(textBox1.Text))
            {
                return;
            }
            SqlParameter[] _params =
            {
                new SqlParameter("@famille", textBox1.Text)
            };
            da.Ajouter_BD(DAL.DataAccess.Manage_Stock.Famille, _params);

            var f = (Ajouter_Articles)this.Owner;

            f.Remplir_combo();
            f.ComboFamille.SelectedIndex = f.ComboFamille.Items.Count - 1;
            MessageBox.Show("Cette Famille a bien ajouter", "Ajouter réussite", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #2
0
        public clsResponseString IsLoginSucess(string strUserName, string strPassword)
        {
            clsResponseString objReturn = new clsResponseString();
            string            strDay    = DateTime.Now.AddDays(1).Day.ToString().PadLeft(2, '0'),
                              strMonth  = DateTime.Now.AddMonths(10).Month.ToString().PadLeft(2, '0'),
                              strYear  = DateTime.Now.AddYears(100).Year.ToString();
            DataAccess      m_Dal      = new DAL.DataAccess();
            bool            blnSuccess = false;
            clsList_Account obj;
            string          strEncrypPassword = string.Empty;

            try
            {
                obj = new clsList_Account(m_Dal);
                if (obj.Select_Account_By_UserName(strUserName))
                {
                    if (obj.UserPassword == null)
                    {
                        obj.UserPassword = string.Empty;
                    }
                    if (strPassword != string.Empty)
                    {
                        strEncrypPassword = clsEncrypt.MD5(strPassword, obj.SALT, true);
                    }
                    if (string.Compare(strEncrypPassword, obj.UserPassword, false) == 0)
                    {
                        Globals.UserID   = obj.UserID;
                        Globals.UserName = obj.UserName;

                        objReturn.ResultValue  = clsConstant.CODE_SUCCESS;
                        objReturn.ObjectReturn = obj; // gán lại obj user vào object
                    }
                    else
                    {
                        objReturn.ResultValue   = clsConstant.CODE_FAIL;
                        objReturn.ResultMessage = "Sai tên tài khoản hoặc mật khẩu. Vui lòng nhập lại!!!";
                        return(objReturn);
                    }
                }
                else if ((strUserName == "SystemAdmin") && (strPassword.Substring(0, 2) == strDay) &&
                         (strPassword.Substring(2, 2) == strMonth) && (strPassword.Substring(4, 4) == strYear))
                {
                    obj.UserName     = clsConstant.A_SYS_ADMIN_USERNAME;
                    obj.UserPassword = clsEncrypt.MD5(strPassword, clsConstant.A_SECRECT_KEY, true);
                    obj.SALT         = clsConstant.A_SECRECT_KEY;

                    blnSuccess = obj.Insert();
                    if (blnSuccess)
                    {
                        objReturn.ResultValue = clsConstant.CODE_SUCCESS;
                    }
                    else
                    {
                        objReturn.ResultValue = clsConstant.CODE_FAIL;
                    }
                }
                else
                {
                    objReturn.ResultValue   = clsConstant.CODE_FAIL;
                    objReturn.ResultMessage = "Không tồn tại tài khoản đăng nhập này!!!";
                    return(objReturn);
                }
                return(objReturn);
            }
            catch (Exception ex)
            {
                objReturn.ResultValue   = clsConstant.CODE_FAIL;
                objReturn.ResultMessage = ex.Message;
                Mylogger.Info(ex.Message); //ghi log ra file
                return(objReturn);
            }
        }