Beispiel #1
0
        public override void SaveBtn_Click(object sender, EventArgs e)
        {
            if (NameTxt.Text == "")
            {
                NameErrorLable.Visible = true;
            }
            else
            {
                NameErrorLable.Visible = false;
            }
            if (FathersNameTxt.Text == "")
            {
                FatherNameErorLable.Visible = true;
            }
            else
            {
                FatherNameErorLable.Visible = false;
            }
            if (EPFID_Txt.Text == "")
            {
                EPFID_ErorLable.Visible = true;
            }
            else
            {
                EPFID_ErorLable.Visible = false;
            }
            if (DOB_Txt.Text == "")
            {
                DOB_ErorLable.Visible = true;
            }
            else
            {
                DOB_ErorLable.Visible = false;
            }
            if (DOJ_Txt.Text == "")
            {
                DOJ_ErorLable.Visible = true;
            }
            else
            {
                DOJ_ErorLable.Visible = false;
            }
            if (EmailTxt.Text == "")
            {
                EmailErorLable.Visible = true;
            }
            else
            {
                EmailErorLable.Visible = false;
            }
            if (Phone1_Txt.Text == "")
            {
                Phone1ErorLable.Visible = true;
            }
            else
            {
                Phone1ErorLable.Visible = false;
            }
            if (Phone1_Txt.Text == Phone2Txt.Text)
            {
                MainClass.ShowMSG("Both phone numbers are same", "Error...", "Error");
            }
            if (PostTxt.Text == "")
            {
                PostErorLable.Visible = true;
            }
            else
            {
                PostErorLable.Visible = false;
            }
            if (StatusDD.SelectedIndex == -1)
            {
                StatusErorLable.Visible = true;
            }
            else
            {
                StatusErorLable.Visible = false;
            }
            if (NameErrorLable.Visible || FatherNameErorLable.Visible || EPFID_ErorLable.Visible || DOB_ErorLable.Visible || DOJ_ErorLable.Visible || EmailErorLable.Visible || Phone1ErorLable.Visible || PostErorLable.Visible || PostErorLable.Visible || StatusErorLable.Visible)
            {
                MainClass.ShowMSG("Feilds With * Are Mendatory", "Error...", "Error");
            }
            else
            {
                if (edit == 0)// Code for save
                {
                    byte  stat = StatusDD.SelectedIndex == 0 ? Convert.ToByte(1) : Convert.ToByte(0);
                    staff s    = new staff();
                    s.st_name         = NameTxt.Text;
                    s.st_fatherName   = FathersNameTxt.Text;
                    s.st_EPFID        = EPFID_Txt.Text;
                    s.st_DOB          = DOB_Txt.Text;
                    s.st_DOJ          = DOJ_Txt.Text;
                    s.st_emailAddress = EmailTxt.Text;
                    s.st_phone1       = Phone1_Txt.Text;
                    s.st_phone2       = Phone2Txt.Text;
                    s.st_Post         = PostTxt.Text;
                    s.st_status       = stat;
                    obj.staffs.InsertOnSubmit(s);
                    obj.SubmitChanges();
                    MainClass.ShowMSG(NameTxt.Text + " Added Successfully", "Success...", "Success");
                    MainClass.disable_reset(panel2);
                    loadData();
                }
                else if (edit == 1)// Code for update
                {
                    var data = obj.staffs.Single(x => x.st_id == staffID);

                    byte stat = StatusDD.SelectedIndex == 0 ? Convert.ToByte(1) : Convert.ToByte(0);
                    data.st_name         = NameTxt.Text;
                    data.st_fatherName   = FathersNameTxt.Text;
                    data.st_EPFID        = EPFID_Txt.Text;
                    data.st_DOB          = DOB_Txt.Text;
                    data.st_DOJ          = DOJ_Txt.Text;
                    data.st_emailAddress = EmailTxt.Text;
                    data.st_phone1       = Phone1_Txt.Text;
                    data.st_phone2       = Phone2Txt.Text;
                    data.st_Post         = PostTxt.Text;
                    data.st_status       = stat;
                    obj.SubmitChanges();
                    MainClass.ShowMSG(NameTxt.Text + " Updated Successfully", "Success...", "Success");
                    MainClass.disable_reset(panel2);
                    loadData();
                }
            }
        }
 partial void Updatestaff(staff instance);
 partial void Deletestaff(staff instance);
 partial void Insertstaff(staff instance);