コード例 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            VPNsRepository vpn = new VPNsRepository();

            if (vpn.FindByUsername(txtusername.Text) != null)
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red);
                return;
            }

            bool successfullCreateAccount = true;

            try
            {
                VPN newvpn = new VPN();
                newvpn.DepartmentID   = ddldepartment.SelectedValue.ToInt();
                newvpn.UserTypeID     = DropDownList1.SelectedValue.ToInt();
                newvpn.UserID         = ddluserid.SelectedValue.ToInt();
                newvpn.Username       = txtusername.Text;
                newvpn.Password       = txtpass.Text;
                newvpn.VPNDescription = txtdes.Text;
                VPNsRepository vpnir = new VPNsRepository();
                vpnir.Savevpn(newvpn);
            }
            catch (System.Exception err)
            {
                successfullCreateAccount = false;
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red);
            }
            if (successfullCreateAccount)
            {
                // ClearForm();
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green);
            }
        }
コード例 #2
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            if (lblid.Text.Length > 0)
            {
                try
                {
                    VPNsRepository vpnir = new VPNsRepository();
                    if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text))
                    {
                        if (vpnir.FindByUsername(txtusername.Text) != null)
                        {
                            PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatemailTitle, Color.Red);
                            return;
                        }
                    }
                    VPN vpn = vpnir.FindvpnByid(lblid.Text.ToInt());
                    vpn.UserTypeID   = Session["UserType"].ToString().ToInt();
                    vpn.UserID       = Session["UserID"].ToString().ToInt();
                    vpn.DepartmentID = Session["DepartmentID"].ToString().ToInt();
                    if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text))
                    {
                        vpn.Username = txtusername.Text;
                    }
                    if ((txtpass.Text != null))
                    {
                        vpn.Password = txtpass.Text;
                    }
                    vpnir.Savevpn(vpn);

                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green);
                }
                catch
                {
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red);
                }
            }
        }