Пример #1
0
        private void SaveInfo(string strLink = "")
        {
            try
            {
                string SALT    = "";
                string USER_PW = "";
                if (!string.IsNullOrEmpty(txtPass.Value))
                {
                    SALT    = Common.CreateSalt();
                    USER_PW = Common.Encrypt(txtPass.Value, SALT);
                }

                if (m_user_id == 0)
                {
                    //insert
                    ESHOP_USER g_insert = new ESHOP_USER();
                    g_insert.USER_NAME   = txtFullName.Value;
                    g_insert.USER_UN     = txtUN.Value;
                    g_insert.USER_ACTIVE = Utils.CIntDef(rblActive.SelectedValue);
                    g_insert.GROUP_ID    = Utils.CIntDef(ddlGroup.SelectedValue);
                    g_insert.USER_PW     = USER_PW;
                    g_insert.SALT        = SALT;

                    DB.ESHOP_USERs.InsertOnSubmit(g_insert);

                    DB.SubmitChanges();

                    strLink = string.IsNullOrEmpty(strLink) ? "user_list.aspx" : strLink;
                }
                else
                {
                    //update
                    var g_update = DB.GetTable <ESHOP_USER>().Where(g => g.USER_ID == m_user_id);

                    if (g_update.ToList().Count > 0)
                    {
                        g_update.Single().USER_NAME   = txtFullName.Value;
                        g_update.Single().USER_UN     = txtUN.Value;
                        g_update.Single().USER_ACTIVE = Utils.CIntDef(rblActive.SelectedValue);
                        g_update.Single().GROUP_ID    = Utils.CIntDef(ddlGroup.SelectedValue);

                        if (!string.IsNullOrEmpty(USER_PW))
                        {
                            g_update.Single().USER_PW = USER_PW;
                            g_update.Single().SALT    = SALT;
                        }

                        DB.SubmitChanges();

                        strLink = string.IsNullOrEmpty(strLink) ? "user_list.aspx" : strLink;
                    }
                }
            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(strLink))
                {
                    Response.Redirect(strLink);
                }
            }
        }
        private void SaveInfo(string strLink = "")
        {
            try
            {
                string SALT = "";
                string USER_PW = "";
                if (!string.IsNullOrEmpty(txtPass.Value))
                {
                    SALT = Common.CreateSalt();
                    USER_PW = Common.Encrypt(txtPass.Value, SALT);
                }

                if (m_user_id == 0)
                {
                    //insert
                    ESHOP_USER g_insert = new ESHOP_USER();
                    g_insert.USER_NAME = txtFullName.Value;
                    g_insert.USER_UN = txtUN.Value;
                    g_insert.USER_ACTIVE = Utils.CIntDef(rblActive.SelectedValue);
                    g_insert.GROUP_ID = Utils.CIntDef(ddlGroup.SelectedValue);
                    g_insert.USER_PW = USER_PW;
                    g_insert.SALT = SALT;

                    DB.ESHOP_USERs.InsertOnSubmit(g_insert);

                    DB.SubmitChanges();

                    strLink = string.IsNullOrEmpty(strLink) ? "user_list.aspx" : strLink;
                }
                else
                {
                    //update
                    var g_update = DB.GetTable<ESHOP_USER>().Where(g => g.USER_ID == m_user_id);

                    if (g_update.ToList().Count > 0)
                    {
                        g_update.Single().USER_NAME = txtFullName.Value;
                        g_update.Single().USER_UN = txtUN.Value;
                        g_update.Single().USER_ACTIVE = Utils.CIntDef(rblActive.SelectedValue);
                        g_update.Single().GROUP_ID = Utils.CIntDef(ddlGroup.SelectedValue);

                        if (!string.IsNullOrEmpty(USER_PW))
                        {
                            g_update.Single().USER_PW = USER_PW;
                            g_update.Single().SALT = SALT;
                        }

                        DB.SubmitChanges();

                        strLink = string.IsNullOrEmpty(strLink) ? "user_list.aspx" : strLink;
                    }
                }

            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(strLink))
                { Response.Redirect(strLink); }
            }
        }