Exemplo n.º 1
0
        protected void EditEducationSecLevel()
        {
            try
            {
                DateTime yearOfAdmn;
                DateTime yrofCompln;
                int      marks   = 0;
                int      ttMarks = 0;
                string   mygradeIs;
                int      optionIs = 0;
                string   uni      = "";
                string   seco;
                string   YroStd;
                var      usname   = Session["username"].ToString();
                var      primo    = lblValues.Text;
                var      grdEmail = txtGuardianEmail.Text.Trim();
                var      grdAddr  = txtGuardianAddress.Text.Trim();

                //int edlev;

                //if (rdoBtnListEdLevel.SelectedIndex ==-1)
                //{
                //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                //        "alert('Please select level of Education first');", true);

                //    return;
                //}
                //else
                //{
                //    edlev = rdoBtnListEdLevel.SelectedIndex;
                //}

                int TorF = rdoBtnListEdLevel.SelectedIndex;
                switch (TorF)
                {
                case 0:
                    optionIs = 0;
                    break;

                case 1:
                    optionIs = 1;
                    break;

                default:
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode", "alert('Please select level of Education first!');", true);
                    break;
                }

                if (ddlSeco.SelectedIndex == 0)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please select secondary school');", true);
                    return;
                }
                else
                {
                    seco = ddlSeco.SelectedItem.Text.Trim();
                }

                if (ddlFormwhat.SelectedIndex == 0)
                {
                    ddlFormwhat.Focus();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please select class!');", true);
                    return;
                }
                else
                {
                    YroStd = ddlFormwhat.SelectedItem.Text;
                }

                var YoAdm = doAdm.Value;
                if (string.IsNullOrWhiteSpace(YoAdm))
                {
                    doAdm.Focus();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please select valid date');", true);
                    return;
                }
                else
                {
                    yearOfAdmn = DateTime.Parse(YoAdm);
                }

                var YoComptn = doEnd.Value;
                if (string.IsNullOrWhiteSpace(YoComptn))
                {
                    doEnd.Focus();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please select valid date');", true);
                    return;
                }
                else
                {
                    yrofCompln = DateTime.Parse(YoComptn);
                }

                if (string.IsNullOrWhiteSpace(txtMarks.Text))
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please Fill in your marks');", true);
                    txtMarks.Focus();
                    txtMarks.BorderColor = Color.Red;
                    return;
                }
                else
                {
                    marks = Convert.ToInt32(txtMarks.Text);
                }
                if (string.IsNullOrWhiteSpace(txtTotalMarks.Text))
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please Fill in total marks');", true);
                    txtTotalMarks.Focus();
                    txtTotalMarks.BorderColor = Color.Red;
                    return;
                }
                else
                {
                    ttMarks = Convert.ToInt32(txtTotalMarks.Text);
                }

                var grdPhne       = txtGuardianPhone.Text.Trim();
                var mobileBuilder = new StringBuilder(grdPhne);
                mobileBuilder.Remove(0, 1);      //Trim one character from position 1
                mobileBuilder.Insert(0, "+254"); // replace position 0 with +254
                grdPhne = mobileBuilder.ToString();

                try
                {
                    if (yrofCompln < yearOfAdmn)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                                "alert('Admision Date should be later than Completion Date!');", true);
                        doEnd.Value = "";
                        doAdm.Value = "";
                        return;
                    }
                }
                catch (Exception ec)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please select correct dates!');", true);
                }

                try
                {
                    var credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"],
                                                            ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
                    var sup = new Portals();
                    sup.Credentials     = credentials;
                    sup.PreAuthenticate = true;
                    if (sup.FnEducatBg(usname, primo, seco, uni, yearOfAdmn, YroStd, yrofCompln, grdPhne, grdEmail,
                                       grdAddr, "", marks, ttMarks, "", optionIs) == true)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                                "alert('Your Education Data Updated Successfully!');", true);
                        // readEducBgData();
                    }
                }
                catch (Exception exc)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('" + exc.Message + "');", true);
                }
            }
            catch (Exception ex)
            {
                KCDFAlert.ShowAlert(ex.Message);
            }
        }