コード例 #1
0
        protected void lvMDGender_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 GenderID;

            Int64.TryParse(e.CommandArgument.ToString(), out GenderID);

            if (GenderID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _GenderID = GenderID;

                    PrepareEditView();

                    cpeEditor.Collapsed   = false;
                    cpeEditor.ClientState = "false";
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(MDGenderEntity.FLD_NAME_GenderID, GenderID.ToString(), SQLMatchType.Equal);

                        MDGenderEntity mDGenderEntity = new MDGenderEntity();


                        result = FCCMDGender.GetFacadeCreate().Delete(mDGenderEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _GenderID       = 0;
                            _MDGenderEntity = new MDGenderEntity();
                            PrepareInitialView();
                            BindMDGenderList();

                            MiscUtil.ShowMessage(lblMessage, "Gender has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Gender.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
コード例 #2
0
        private void UserInfo()
        {
            string Name;
            string Surname;
            string PhoneNumber;
            string EmailAddress;
            string UserName;
            string UserPassword;
            int    PrivilegeID;
            int    GenderID;
            int    TitleID;
            string GenderDescription;
            int    UserTypeID;
            string PrivilegeDescription;
            string UserTypeDescription;
            string TitleDescription;


            SqlConnection sqlcon = new SqlConnection(Globals.ConnectionString);

            sqlcon.Open();
            string        cmd    = "SELECT * FROM Users Where UserID ='" + Globals.SelectedUserID.ToString() + "'";
            SqlCommand    sqlcom = new SqlCommand(cmd, sqlcon);
            SqlDataReader dr     = sqlcom.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    //    try
                    //    {
                    Name         = (dr["Name"].ToString());
                    Surname      = (dr["Surname"].ToString());
                    PhoneNumber  = (dr["PhoneNumber"].ToString());
                    UserName     = (dr["UserName"].ToString());
                    UserPassword = (dr["UserPassword"].ToString());
                    PrivilegeID  = Convert.ToInt32((dr["PrivilegeID"]));
                    GenderID     = Convert.ToInt32((dr["GenderID"]));
                    TitleID      = Convert.ToInt32((dr["TitleID"]));
                    UserTypeID   = Convert.ToInt32((dr["UserTypeID"]));
                    EmailAddress = (dr["EmailAddress"].ToString());

                    txtName.Text         = Name;
                    txtSurname.Text      = Surname;
                    txtPhoneNumber.Text  = PhoneNumber;
                    txtUsername.Text     = UserName;
                    txtPassword.Text     = UserPassword;
                    txtEmailAddress.Text = EmailAddress;

                    //Get Gender
                    SqlConnection sqlcon2 = new SqlConnection(Globals.ConnectionString);
                    sqlcon2.Open();
                    string        cmd2    = "SELECT GenderDescription FROM Gender WHERE GenderID ='" + GenderID.ToString() + "'";
                    SqlCommand    sqlcom2 = new SqlCommand(cmd2, sqlcon2);
                    SqlDataReader dr2;
                    dr2 = sqlcom2.ExecuteReader();
                    if (dr2.HasRows)
                    {
                        while (dr2.Read())
                        {
                            GenderDescription = (dr2["GenderDescription"].ToString());
                            cbxGender.Text    = GenderDescription;
                        }
                    }
                    dr2.Close();
                    sqlcon2.Close();

                    //Get Title
                    SqlConnection sqlcon3 = new SqlConnection(Globals.ConnectionString);
                    sqlcon3.Open();
                    string        cmd3    = "SELECT TitleDescription FROM Title WHERE TitleID ='" + TitleID.ToString() + "'";
                    SqlCommand    sqlcom3 = new SqlCommand(cmd3, sqlcon3);
                    SqlDataReader dr3;
                    dr3 = sqlcom3.ExecuteReader();
                    if (dr3.HasRows)
                    {
                        while (dr3.Read())
                        {
                            TitleDescription = (dr3["TitleDescription"].ToString());
                            cbxTitle.Text    = TitleDescription;
                        }
                    }
                    dr3.Close();
                    sqlcon3.Close();

                    //Get Privilege
                    SqlConnection sqlcon4 = new SqlConnection(Globals.ConnectionString);
                    sqlcon4.Open();
                    string        cmd4    = "SELECT PrivilegeDescription FROM Privilege WHERE PrivilegeID ='" + PrivilegeID.ToString() + "'";
                    SqlCommand    sqlcom4 = new SqlCommand(cmd4, sqlcon4);
                    SqlDataReader dr4;
                    dr4 = sqlcom4.ExecuteReader();
                    if (dr4.HasRows)
                    {
                        while (dr4.Read())
                        {
                            PrivilegeDescription  = (dr4["PrivilegeDescription"].ToString());
                            cbxPrivilegeType.Text = PrivilegeDescription;
                        }
                    }
                    dr4.Close();
                    sqlcon4.Close();

                    //Get UserType
                    SqlConnection sqlcon5 = new SqlConnection(Globals.ConnectionString);
                    sqlcon5.Open();
                    string        cmd5    = "SELECT UserDescription FROM UserType WHERE UserTypeID ='" + UserTypeID.ToString() + "'";
                    SqlCommand    sqlcom5 = new SqlCommand(cmd5, sqlcon5);
                    SqlDataReader dr5;
                    dr5 = sqlcom5.ExecuteReader();
                    if (dr5.HasRows)
                    {
                        while (dr5.Read())
                        {
                            UserTypeDescription = (dr5["UserDescription"].ToString());
                            cbxUserType.Text    = UserTypeDescription;
                        }
                    }
                    dr5.Close();
                    sqlcon5.Close();
                    //     }
                    //    catch
                    //    {


                    //   }
                }
            }
            dr.Close();
            sqlcon.Close();
        }