Пример #1
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            int      flag = 1;
            Eng_info ef   = new Eng_info();

            ef.name = TextBox1.Text.Trim();
            ef.no   = TextBox2.Text.Trim();
            if (TextBox3.Text.Trim() == "男" || TextBox3.Text.Trim() == "女")
            {
                ef.sex = TextBox3.Text.Trim();
            }
            else
            {
                flag          = 0;
                Label_st.Text = "Add->ERROR,性别只能为男或女";
            }

            ef.address   = TextBox4.Text.Trim();
            ef.telephone = TextBox5.Text.Trim();
            try
            {
                ef.working_age = Convert.ToInt32(TextBox6.Text.Trim());
            }
            catch (Exception error)
            {
                Label_st.Text = "Add->ERROR,工龄不是整数型";
                flag          = 0;
            }
            ef.basic_salary = TextBox7.Text;
            try
            {
                ef.birthday = Convert.ToDateTime(TextBox8.Text.Trim());
            }
            catch (Exception error)
            {
                Label_st.Text = "Add->ERROR,生日不是日期型 格式为:YYYY-MM-DD";
                flag          = 0;
            }
            ef.education = TextBox9.Text.Trim();
            var jugle = from item in linq.Eng_info
                        where item.no == ef.no
                        select item;

            if (jugle.Count() == 0 && flag == 1 && TextBox1.Text != "" && TextBox2.Text != "" && TextBox3.Text != "" && TextBox4.Text != "" && TextBox5.Text != "" && TextBox6.Text != "" && TextBox7.Text != "" && TextBox8.Text != "" && TextBox9.Text != "")
            {
                linq.Eng_info.InsertOnSubmit(ef);
                linq.SubmitChanges();
                dataload();
                Label_st.Text   = "Add->succeed!";
                Button5.Enabled = false;


                Label_at.Text = "Select first, then operate";
            }
            else if (jugle.Count() != 0 && flag == 1)
            {
                Label_st.Text = "Add->ERROR,编号重复!";
            }
            else if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "" || TextBox4.Text == "" || TextBox5.Text == "" || TextBox6.Text == "" || TextBox7.Text == "" || TextBox8.Text == "" || TextBox9.Text == "")
            {
                Label_st.Text = "Add->ERROR,    有内容为空!";
            }
        }
Пример #2
0
        protected void Button5_Click(object sender, EventArgs e)
        {
            int flag = 1;
            var up   = from item in linq.Eng_info
                       where item.no == TextBox2.Text
                       select item;

            if (up.Count() != 0)
            {
                foreach (Eng_info ef in up)
                {
                    ef.name = TextBox1.Text.Trim();
                    ef.no   = TextBox2.Text.Trim();
                    if (TextBox3.Text.Trim() == "男" || TextBox3.Text.Trim() == "女")
                    {
                        ef.sex = TextBox3.Text.Trim();
                    }
                    else
                    {
                        flag          = 0;
                        Label_st.Text = "Alter->ERROR,性别只能为男或女";
                    }
                    ef.address   = TextBox4.Text.Trim();
                    ef.telephone = TextBox5.Text.Trim();
                    try
                    {
                        ef.working_age = Convert.ToInt32(TextBox6.Text.Trim());
                    }
                    catch (Exception error)
                    {
                        Label_st.Text = "Alter->ERROR,工龄不是整数型";
                        flag          = 0;
                    }

                    ef.basic_salary = TextBox7.Text.Trim();
                    try
                    {
                        ef.birthday = Convert.ToDateTime(TextBox8.Text.Trim());
                    }
                    catch (Exception error)
                    {
                        Label_st.Text = "Alter->ERROR,生日不是日期型 格式为:YYYY-MM-DD";
                        flag          = 0;
                    }
                    ef.education = TextBox9.Text;
                    if (flag == 1 && TextBox1.Text != "" && TextBox2.Text != "" && TextBox3.Text != "" && TextBox4.Text != "" && TextBox5.Text != "" && TextBox6.Text != "" && TextBox7.Text != "" && TextBox8.Text != "" && TextBox9.Text != "")
                    {
                        if (TextBox2.Text != temp)
                        {
                            var del = from item in linq.Eng_info
                                      where item.no == temp
                                      select item;

                            linq.Eng_info.DeleteAllOnSubmit(del);
                        }



                        linq.SubmitChanges();
                    }
                }
                if (flag == 1 && TextBox1.Text != "" && TextBox2.Text != "" && TextBox3.Text != "" && TextBox4.Text != "" && TextBox5.Text != "" && TextBox6.Text != "" && TextBox7.Text != "" && TextBox8.Text != "" && TextBox9.Text != "")
                {
                    dataload();
                    Label_st.Text   = "Alter->Succeed";
                    Button5.Enabled = false;


                    Label_at.Text = "Select first, then operate";
                }
                else if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "" || TextBox4.Text == "" || TextBox5.Text == "" || TextBox6.Text == "" || TextBox7.Text == "" || TextBox8.Text == "" || TextBox9.Text == "")
                {
                    Label_st.Text = "Alter->ERROR,有内容为空!";
                }
            }
            else
            {
                Eng_info ef = new Eng_info();
                ef.name      = TextBox1.Text.Trim();
                ef.no        = TextBox2.Text.Trim();
                ef.sex       = TextBox3.Text.Trim();
                ef.address   = TextBox4.Text.Trim();
                ef.telephone = TextBox5.Text.Trim();
                try
                {
                    ef.working_age = Convert.ToInt32(TextBox6.Text.Trim());
                }
                catch (Exception error)
                {
                    Label_st.Text = "Alter->ERROR,工龄不是整数型";
                    flag          = 0;
                }

                ef.basic_salary = TextBox7.Text.Trim();
                try
                {
                    ef.birthday = Convert.ToDateTime(TextBox8.Text.Trim());
                }
                catch (Exception error)
                {
                    Label_st.Text = "Alter->ERROR,生日不是日期型 格式为:YYYY-MM-DD";
                    flag          = 0;
                }
                ef.education = TextBox9.Text;
                if (flag == 1 && TextBox1.Text != "" && TextBox2.Text != "" && TextBox3.Text != "" && TextBox4.Text != "" && TextBox5.Text != "" && TextBox6.Text != "" && TextBox7.Text != "" && TextBox8.Text != "" && TextBox9.Text != "")
                {
                    var del = from item in linq.Eng_info
                              where item.no == temp
                              select item;

                    linq.Eng_info.DeleteAllOnSubmit(del);
                    linq.Eng_info.InsertOnSubmit(ef);
                    linq.SubmitChanges();
                    dataload();
                    Label_st.Text   = "Alter->Succeed";
                    Button5.Enabled = false;


                    Label_at.Text = "Select first, then operate";
                }
                else if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "" || TextBox4.Text == "" || TextBox5.Text == "" || TextBox6.Text == "" || TextBox7.Text == "" || TextBox8.Text == "" || TextBox9.Text == "")
                {
                    Label_st.Text = "Alter->ERROR,有内容为空!";
                }
            }
        }
Пример #3
0
 partial void UpdateEng_info(Eng_info instance);
Пример #4
0
 partial void DeleteEng_info(Eng_info instance);
Пример #5
0
 partial void InsertEng_info(Eng_info instance);