Example #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            using (TranMng TM = new TranMng())
            {
                LoginDao LD = new LoginDao();
                string   id = TextBox1.Text;

                DUser duser = LD.Login(id);

                if (duser != null)
                {
                    if (duser.Password == TextBox2.Text)
                    {
                        Session["id"] = duser.UserId;
                        Server.Transfer("Menu.aspx");
                    }
                    else
                    {
                        Server.Transfer("LoginError.html");
                    }
                }
                else
                {
                    Server.Transfer("LoginError.html");
                }
            }
        }
Example #2
0
        /// <summary>
        /// ページを読み込むときのメソッド
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //テーブルの列数
            const int TABLENUM = 7;
            //データベースの列数
            const int MAXNUM = 9;
            //参照したいListの数
            int listNum;

            using (TranMng trn = new TranMng()) {
                //DAOのインスタンス
                Dao           dao = new Dao();
                List <string> member;

                //登録情報の取得
                member = dao.Show();

                //テーブルに値を代入
                //i = 行数
                for (int i = 0; i < member.Count / MAXNUM; i++)
                {
                    //参照したいListの初期化
                    listNum = 0;
                    //テーブルの作成
                    TableRow row = new TableRow();
                    Table1.Rows.Add(row);
                    row.Cells.AddRange(new TableCell[] { new TableCell(), new TableCell(), new TableCell(), new TableCell(), new TableCell(), new TableCell(), new TableCell(), new TableCell() });
                    for (int j = 0; j <= TABLENUM; j++)
                    {
                        row.Cells[j].HorizontalAlign = HorizontalAlign.Center;
                        switch (j)
                        {
                        //テーブル1番目には氏List(1) + 名List(2)
                        //テーブル2番目には氏フリガナList(3) + 名フリガナList(4)
                        case 1:
                        case 2:
                            row.Cells[j].Text = member[listNum + (i * MAXNUM)] + member[listNum + (i * MAXNUM) + 1];
                            listNum          += 2;
                            break;

                        //テーブルの最後に"削除"ボタンの作成
                        case TABLENUM:
                            Button deleteButton = new Button();
                            deleteButton.Text = " " + "削除";
                            //行のコード情報(削除したい従業員コード)
                            deleteButton.ID     = member[i * MAXNUM];
                            deleteButton.Click += new EventHandler(Remover_ButtonClick);
                            row.Cells[j].Controls.Add(deleteButton);
                            break;

                        //Listの情報をテーブルに挿入
                        default:
                            row.Cells[j].Text = member[listNum + (i * MAXNUM)];
                            listNum++;
                            break;
                        }
                    }
                }
            }
        }
Example #3
0
        protected void CreateUser_Button_Click(object sender, EventArgs e)
        {
            string id       = ID_TextBox.Text;
            string pw       = PW_TextBox.Text;
            string pw_cheak = PW_Check.Text;

            if (id != "" && pw != "")
            {
                if (pw == pw_cheak)
                {
                    using (TranMng TM = new TranMng())
                    {
                        UserDao ID  = new UserDao();
                        string  msg = ID.Insert(ID_TextBox.Text, PW_TextBox.Text);
                        Session.Add("msg", msg);
                        Server.Transfer("Result.aspx");
                    }
                }
                else
                {
                    Error.Text = "パスワードが一致しません。";
                }
            }
            else
            {
                Error.Text = "未入力の内容があります。";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //ユーザー一覧で選択した従業員の情報を最初から表示したい
                EUser EU = new EUser();
                using (TranMng TM = new TranMng())
                {
                    string UserId = Session["UserId"].ToString();
                    user.Text = UserId;
                    //選んだユーザーの情報をエンティティに保存
                    SelectDao SD = new SelectDao();
                    EU                 = SD.Select(UserId);
                    last_nm.Text       = EU.last_nm;
                    first_nm.Text      = EU.first_nm;
                    last_nm_kana.Text  = EU.last_nm_kana;
                    first_nm_kana.Text = EU.first_nm_kana;
                }

                DropDownList1.SelectedIndex = EU.gender_cd;

                ListItem li2         = DropDownList2.Items.FindByValue(EU.section_cd);
                int      section_idx = DropDownList2.Items.IndexOf(li2);
                DropDownList2.SelectedIndex = section_idx;
            }
        }
 protected void DeleteButton_Click(object sender, EventArgs e)
 {
     using (TranMng TM = new TranMng())
     {
         DeleteDao DD    = new DeleteDao();
         string    error = DD.Delete(Emp_Cd_List.Text);
         Session.Add("msg", error);
         Server.Transfer("Result.aspx");
     }
 }
 protected void Button1_Click(object sender, EventArgs e)
 {
     using (TranMng TM = new TranMng())
     {
         UpDateDao UD  = new UpDateDao();
         string    msg = UD.UpDate(user.Text, last_nm.Text, first_nm.Text, last_nm_kana.Text, first_nm_kana.Text, int.Parse(DropDownList1.Text), DropDownList2.Text);
         Session.Add("msg", msg);
         Server.Transfer("Result.aspx");
     }
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox4.Text == "" || DropDownList1.Text == "")
            {
                Label1.Text = "未入力の項目があります";
            }
            else
            {
                using (TranMng TM = new TranMng())
                {
                    //現在保存しているセッションを削除
                    EmployeeDao EmpD = new EmployeeDao();
                    Session.Remove("msg");
                    string error = "";
                    int    count = EmpD.IDcheck(TextBox1.Text);
                    if (count != 0)
                    {
                        Label1.Text = "その従業員コードは使われています。";
                    }
                    else
                    {
                        //try
                        //{
                        //入力された情報をインサート文に渡す。
                        //エラーにはエラーメッセージが返ってくる
                        string BirthDay = BirthYearList.Text + "/" + BirthMonthList.Text + "/" + BirthDayList.Text;
                        string Join     = JoinYearList.Text + "/" + JoinMonthList.Text + "/" + JoinDayList.Text;
                        error = EmpD.Insert(TextBox1.Text, TextBox2.Text, TextBox4.Text, TextBox3.Text, TextBox5.Text, int.Parse(DropDownList1.Text), BirthDay, DropDownList2.Text, Join);

                        //}
                        ////catch (FormatException)
                        ////{
                        ////    Label1.Text = "未入力項目があります";
                        ////}
                        ////Server.Transfer("Result.aspx");
                        //catch (FormatException)
                        //{
                        //    Label1.Text = "未入力項目があります。";
                        //}
                        Session.Add("msg", error);
                        Server.Transfer("Result.aspx");
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                using (TranMng TM = new TranMng())
                {
                    SelectDao SD    = new SelectDao();
                    int       count = SD.Select();
                    if (count == 0)
                    {
                        Emp_Cd_List.Visible  = false;
                        DeleteButton.Visible = false;
                    }
                }
            }

            DeleteButton.Attributes["OnClick"] = "return confirm('本当に削除しますか?');";
        }
Example #9
0
        //ログインボタンが押されたとき
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            bool   loginFlag = true;
            string userId    = UserID.Text;
            string password  = Password.Text;

            using (TranMng trn = new TranMng()) {
                Dao dao = new Dao();

                loginFlag = dao.Login(userId, password);
            }
            // flagがtrueならメニュー画面へ遷移・falseならエラー画面1に遷移
            if (loginFlag)
            {
                Server.Transfer("Menu.aspx");
            }
            else
            {
                Server.Transfer("Error1.html");
            }
        }
Example #10
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     using (TranMng TM = new TranMng())
     {
         //現在保存しているセッションを削除
         InsertDao ID = new InsertDao();
         Session.Remove("msg");
         string error = "";
         try
         {
             //入力された情報をインサート文に渡す。
             //エラーにはエラーメッセージが返ってくる
             string BirthDay = BirthYearList.Text + "/" + BirthMonthList.Text + "/" + BirthDayList.Text;
             string Join     = JoinYearList.Text + "/" + JoinMonthList.Text + "/" + JoinDayList.Text;
             error = ID.Insert(TextBox1.Text, TextBox2.Text, TextBox4.Text, TextBox3.Text, TextBox5.Text, int.Parse(DropDownList1.Text), BirthDay, DropDownList2.Text, Join);
         }
         catch (FormatException)
         {
             error = "未入力項目があります。";
         }
         Session.Add("msg", error);
         Server.Transfer("Result.aspx");
     }
 }