Ejemplo n.º 1
0
    protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        UpdatePanel  up4 = (UpdatePanel)(FormView1.FindControl("UpdatePanel4"));
        DropDownList dl1 = (DropDownList)(up4.FindControl("DropDownList6"));

        UpdatePanel  up5 = (UpdatePanel)(up4.FindControl("UpdatePanel5"));
        DropDownList dl2 = (DropDownList)(up5.FindControl("DropDownList7"));

        UpdatePanel  up6 = (UpdatePanel)(up5.FindControl("UpdatePanel6"));
        DropDownList dl3 = (DropDownList)(up6.FindControl("DropDownList8"));

        string     q   = "insert into user_Info (userName, firstName, lastName,userGender,contactNumber, userAddress, userCountry, userState, userCity, postalCode) values (@userName, @firstName, @lastName, @userGender,@contactNumber, @userAddress, @userCountry, @userState, @userCity, @postalCode)";
        SqlCommand cmd = new SqlCommand(q, con);

        cmd.Parameters.Add("@userName", SqlDbType.VarChar, 50).Value     = Label3.Text;
        cmd.Parameters.Add("@firstName", SqlDbType.VarChar, 50).Value    = ((TextBox)(FormView1.FindControl("TextBox6"))).Text;
        cmd.Parameters.Add("@lastName", SqlDbType.VarChar, 50).Value     = ((TextBox)(FormView1.FindControl("TextBox7"))).Text;
        cmd.Parameters.Add("@userGender", SqlDbType.VarChar, 50).Value   = (((DropDownList)(FormView1.FindControl("DropDownList5"))).SelectedValue).ToString();
        cmd.Parameters.Add("@contactNumber", SqlDbType.BigInt).Value     = Convert.ToInt64(((TextBox)(FormView1.FindControl("TextBox8"))).Text);
        cmd.Parameters.Add("@userAddress", SqlDbType.NVarChar, 50).Value = ((TextBox)(FormView1.FindControl("TextBox9"))).Text;
        cmd.Parameters.Add("@userCountry", SqlDbType.VarChar, 50).Value  = dl1.SelectedValue;
        cmd.Parameters.Add("@userState", SqlDbType.VarChar, 50).Value    = dl2.SelectedValue;
        cmd.Parameters.Add("@userCity", SqlDbType.VarChar, 50).Value     = dl3.SelectedValue;
        cmd.Parameters.Add("@postalCode", SqlDbType.Int).Value           = Convert.ToInt32(((TextBox)(FormView1.FindControl("TextBox10"))).Text);

        cmd.ExecuteNonQuery();
        cmd.Dispose();
        con.Close();
        FormView1.ChangeMode(FormViewMode.ReadOnly);
        bind();
    }
Ejemplo n.º 2
0
    protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        UpdatePanel  up1 = (UpdatePanel)(FormView1.FindControl("UpdatePanel7"));
        DropDownList dl1 = (DropDownList)(up1.FindControl("DropDownList9"));

        UpdatePanel  up2 = (UpdatePanel)(up1.FindControl("UpdatePanel8"));
        DropDownList dl2 = (DropDownList)(up2.FindControl("DropDownList10"));

        UpdatePanel  up3 = (UpdatePanel)(up2.FindControl("UpdatePanel9"));
        DropDownList dl3 = (DropDownList)(up3.FindControl("DropDownList11"));

        string     q   = "update user_Info set firstName=@firstName,lastName=@lastName,userGender=@userGender,contactNumber=@contactNumber,userAddress=@userAddress,userCountry=@userCountry,userState=@userState,userCity=@userCity where userName=@userName";
        SqlCommand cmd = new SqlCommand(q, con);

        cmd.Parameters.Add("@userName", SqlDbType.VarChar, 50).Value     = FormView1.DataKey["userName"];
        cmd.Parameters.Add("@firstName", SqlDbType.VarChar, 50).Value    = ((TextBox)(FormView1.FindControl("TextBox1"))).Text;
        cmd.Parameters.Add("@lastName", SqlDbType.VarChar, 50).Value     = ((TextBox)(FormView1.FindControl("TextBox2"))).Text;
        cmd.Parameters.Add("@userGender", SqlDbType.VarChar, 50).Value   = (((DropDownList)(FormView1.FindControl("DropDownList1"))).SelectedValue).ToString();
        cmd.Parameters.Add("@contactNumber", SqlDbType.BigInt).Value     = Convert.ToInt64(((TextBox)(FormView1.FindControl("TextBox3"))).Text);
        cmd.Parameters.Add("@userAddress", SqlDbType.NVarChar, 50).Value = ((TextBox)(FormView1.FindControl("TextBox4"))).Text;
        cmd.Parameters.Add("@userCountry", SqlDbType.VarChar, 50).Value  = dl1.SelectedValue;
        cmd.Parameters.Add("@userState", SqlDbType.VarChar, 50).Value    = dl2.SelectedValue;
        cmd.Parameters.Add("@userCity", SqlDbType.VarChar, 50).Value     = dl3.SelectedValue;
        cmd.Parameters.Add("@postalCode", SqlDbType.Int).Value           = Convert.ToInt32(((TextBox)(FormView1.FindControl("TextBox5"))).Text);

        cmd.ExecuteNonQuery();
        cmd.Dispose();
        con.Close();
        FormView1.ChangeMode(FormViewMode.ReadOnly);
        bind();
    }
        protected void ListViewUsers_ItemEditing(object sender, ListViewEditEventArgs e)
        {
            ListViewUsers.EditIndex = e.NewEditIndex;
            PopulateListViewUsers();

            if (this.ListViewUsers.EditIndex != -1)
            {
                Panel         validationMsg           = (Panel)this.ListViewUsers.Items[this.ListViewUsers.EditIndex].FindControl("editNameContainerIsValid");
                UpdatePanel   updatePanel             = (UpdatePanel)this.ListViewUsers.Items[this.ListViewUsers.EditIndex].FindControl("UpdatePanelEdit");
                TextBox       TextBoxUserNameEdit     = (TextBox)updatePanel.FindControl("TextBoxUsernameEdit");
                CheckBoxList  CheckBoxListRolesOfUser = (CheckBoxList)updatePanel.FindControl("CheckBoxListRolesOfUser");
                Literal       ListeralApplicationName = (Literal)updatePanel.FindControl("LiteralAppNameEdit");
                List <String> userRolesList           = RolesBLL.GetRolesForUserByApplication(ListeralApplicationName.Text, TextBoxUserNameEdit.Text);
                List <String> applicationRolesList    = RolesBLL.GetRolesByApplication(ListeralApplicationName.Text);

                validationMsg.Visible = false;

                foreach (string applicationRole in applicationRolesList)
                {
                    System.Web.UI.WebControls.ListItem listItem = new System.Web.UI.WebControls.ListItem(applicationRole, "", true);

                    foreach (string userRole in userRolesList)
                    {
                        if (applicationRole == userRole)
                        {
                            listItem.Selected = true;
                        }
                    }

                    CheckBoxListRolesOfUser.Items.Add(listItem);
                }
            }
        }
Ejemplo n.º 4
0
    protected void Regist_Trigger()
    {
        foreach (Control ctl in Page.Master.FindControl("ContentPlaceHolder1").Controls)
        {
            //Utility.log(1, ctl.ID.ToString());
            if (ctl.GetType().Name == "UpdatePanel")
            {
                UpdatePanel p = (UpdatePanel)ctl;

                string name = p.ID.Replace("panel_", "btn_");
                string type = p.ID.Replace("panel_", "");

                Button btn = (Button)p.FindControl(name);

                btn.Text = getStr("upload_file");

                //因為fileUpload 在postback 後,上傳功能會鎖住 所以必需要重新註冊
                //https://dotblogs.com.tw/stanley14/2016/08/10/173019 參考這篇 重新註冊 trigger
                PostBackTrigger trigger = new PostBackTrigger();
                trigger.ControlID = btn.ID;
                p.Triggers.Add(trigger);
                ScriptManager.GetCurrent(Page).RegisterPostBackControl(btn);

                if (_attach.Rows.Count > 0)
                {
                    attach_List(type);
                }
            }
        }
    }
Ejemplo n.º 5
0
    //Method for Booking An Appointment
    public void MyBookingBtnHanlder(object sender, ImageClickEventArgs e)
    {
        HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

        if (authCookie != null)
        {
            //Check if the patient already have any up to date appointment
            if (CheckPendantBookings() == false)
            {
                ImageButton imgbtn = (ImageButton)sender;
                CultureInfo ci     = new CultureInfo("en-US");
                DateTime    date   = Convert.ToDateTime(imgbtn.CommandArgument);

                TimeSpan time = date.TimeOfDay;
                date = date.Date;
                int result = 0;

                try
                {
                    var query = from a in db.Appointment
                                where a.Date == date && a.Time == time && a.Status == true
                                select a;

                    result = query.Count();
                }
                catch (Exception) { }

                //Check if some other patient booked that time before the current patient selected it
                if (result > 0)
                {
                    Label label = (Label)UpdatePanel.FindControl("BookingErrorMessage");
                    label.Text    = "Sorry, someone came ahead of you and has booked that time";
                    label.Visible = true;
                }
                //Else book the appointment
                else
                {
                    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);

                    //Wait until is safe to enter
                    mutex.WaitOne();

                    try
                    {
                        var patient = (from p in db.Patient
                                       where p.NhsNumber == ticket.Name
                                       select p).First();

                        Appointment appointment = new Appointment
                        {
                            Date            = date,
                            Time            = time,
                            BookingDateTime = DateTime.Now,
                            Status          = true,
                            PatientFk       = patient.Id
                        };

                        db.Appointment.InsertOnSubmit(appointment);
                        db.SubmitChanges();
                    }
                    catch (Exception) { }

                    //Release the Mutex
                    mutex.ReleaseMutex();
                    Response.Redirect("PatientPanel.aspx?success=yes");
                }
            }
            //Else if the patient already has a pendant appointment
            else
            {
                Response.Redirect("PatientPanel.aspx?error=yes");
            }
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
Ejemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

        if (authCookie != null)
        {
            PageHeader.Text = string.Format("<h3 class='page-header-lg'>{0}</h3>", "Book an Appointment");

            Label label = (Label)UpdatePanel.FindControl("BookingErrorMessage");
            label.Visible = false;

            //Check if the page has not been posted back
            if (!IsPostBack)
            {
                DateTime today   = DateTime.Today;
                DateTime nextDay = today.AddDays(1);

                CultureInfo ci = new CultureInfo("en-US");

                //Fill the RadioButtonList with the 5 following days of the week except Saturday and Sunday
                for (int i = 0; i < 5; i++)
                {
                    ListItem item = new ListItem();

                    if (nextDay.ToString("dddd", ci) == DayOfWeek.Saturday.ToString())
                    {
                        nextDay    = nextDay.AddDays(2);
                        item.Text  = nextDay.ToString("dddd d MMMM", ci);
                        item.Value = nextDay.ToString("yyyy-MM-dd");
                        RadioButtonList.Items.Add(item);
                    }

                    else if (nextDay.ToString("dddd", ci) == DayOfWeek.Sunday.ToString())
                    {
                        nextDay    = nextDay.AddDays(1);
                        item.Text  = nextDay.ToString("dddd d MMMM", ci);
                        item.Value = nextDay.ToString("yyyy-MM-dd");
                        RadioButtonList.Items.Add(item);
                    }
                    else
                    {
                        item.Text  = nextDay.ToString("dddd d MMMM", ci);
                        item.Value = nextDay.ToString("yyyy-MM-dd");
                        RadioButtonList.Items.Add(item);
                    }
                    nextDay = nextDay.AddDays(1);
                }
            }

            //Else show Available Hours Table located in the Update Panel (AJAX)
            else
            {
                var selectedDate = RadioButtonList.SelectedValue;

                //Check if the patient has already selected a day
                if (selectedDate != "")
                {
                    int      rowCtr, cellCtr;
                    TimeSpan time;
                    DateTime date = Convert.ToDateTime(selectedDate);

                    for (rowCtr = -15; rowCtr <= 45; rowCtr = rowCtr + 15)
                    {
                        TableRow tRow = new TableRow();
                        Table.Rows.Add(tRow);

                        for (cellCtr = 8; cellCtr <= 18; cellCtr++)
                        {
                            TableCell tCell = new TableCell();
                            tRow.Cells.Add(tCell);

                            ImageButton btn = new ImageButton();
                            Image       img = new Image();
                            img.ImageUrl = "NULL";

                            if (rowCtr == -15)
                            {
                                if (cellCtr != 18)
                                {
                                    img.ImageUrl = "./img/" + cellCtr + ".png";
                                    img.CssClass = "img-hour";
                                }
                                else
                                {
                                    img = new Image();
                                }
                            }
                            else
                            {
                                if (cellCtr == 18)
                                {
                                    if (rowCtr == 15)
                                    {
                                        img.ImageUrl = "./img/15'.png";
                                    }

                                    else
                                    {
                                        img.ImageUrl = "./img/" + rowCtr + ".png";
                                        img.CssClass = "img-hour";
                                    }
                                }
                                else
                                {
                                    time = new TimeSpan(cellCtr, rowCtr, 0);

                                    var query = from a in db.Appointment
                                                where a.Date == date && a.Time == time && a.Status == true
                                                select a;

                                    if (query.Count() <= 0)
                                    {
                                        btn.ImageUrl = "./img/book.png";
                                        btn.Attributes.Add("class", "btn-img");
                                        btn.ID = cellCtr + "-" + rowCtr;

                                        date = date.Date + time;
                                        btn.CommandArgument = date.ToString();
                                        btn.Click          += MyBookingBtnHanlder;
                                    }
                                    else
                                    {
                                        img.ImageUrl = "./img/booked.png";
                                        img.Attributes.Add("class", "img-hour");
                                    }
                                }
                            }

                            if (img.ImageUrl != "NULL")
                            {
                                tCell.Controls.Add(img);
                            }
                            else
                            {
                                tCell.Controls.Add(btn);
                            }
                        }
                    }
                }
            }
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
Ejemplo n.º 7
0
    private void BindAg_WFP3()
    {
        using (WACDataClassesDataContext wDataContext = new WACDataClassesDataContext())
        {
            ListView lv;

            var a = wDataContext.form_wfp3s.Where(w => w.pk_form_wfp3 == PK_FormWfp3).Select(s => s);
            fvAg_WFP3.DataKeyNames = new string[] { "pk_form_wfp3" };
            fvAg_WFP3.DataSource   = a;
            fvAg_WFP3.DataBind();

            //lvAg_WFP3_BMPs
            lv = pnlSubPanels.FindControl("lvAg_WFP3_BMPs") as ListView;
            var c = from b in wDataContext.vw_form_wfp3_BMPs.Where(w => w.pk_form_wfp3 == PK_FormWfp3) select b;
            lv.DataKeyNames = new string[] { "pk_form_wfp3_bmp" };
            lv.DataSource   = c;
            lv.DataBind();

            //lvAg_WFP3_Bids
            lv = pnlSubPanels.FindControl("lvAg_WFP3_Bids") as ListView;
            var d = from b in wDataContext.form_wfp3_bids.Where(w => w.fk_form_wfp3 == PK_FormWfp3) select b;
            lv.DataKeyNames = new string[] { "pk_form_wfp3_bid" };
            lv.DataSource   = d;
            lv.DataBind();

            //lvAg_WFP3_Encumbrances
            lv = pnlSubPanels.FindControl("lvAg_WFP3_Encumbrances") as ListView;
            var e = from b in wDataContext.form_wfp3_encumbrances.Where(w => w.fk_form_wfp3 == PK_FormWfp3) select b;
            lv.DataKeyNames = new string[] { "pk_form_wfp3_encumbrance" };
            lv.DataSource   = e;
            lv.DataBind();

            //lvAg_WFP3_Invoices
            lv = pnlSubPanels.FindControl("lvAg_WFP3_Invoices") as ListView;
            var i = from b in wDataContext.form_wfp3_invoices.Where(w => w.fk_form_wfp3 == PK_FormWfp3) select b;
            lv.DataKeyNames = new string[] { "pk_form_wfp3_invoice" };
            lv.DataSource   = i;
            lv.DataBind();

            //lvAg_WFP3_Payments
            lv = pnlSubPanels.FindControl("lvAg_WFP3_Payments") as ListView;
            var p = from b in wDataContext.form_wfp3_payments.Where(w => w.fk_form_wfp3 == PK_FormWfp3) select b;
            lv.DataKeyNames = new string[] { "pk_form_wfp3_payment" };
            lv.DataSource   = p;
            lv.DataBind();

            //lvAg_WFP3_Modifications
            lv = pnlSubPanels.FindControl("lvAg_WFP3_Modifications") as ListView;
            var m = from b in wDataContext.form_wfp3_modifications.Where(w => w.fk_form_wfp3 == PK_FormWfp3) select b;
            lv.DataKeyNames = new string[] { "pk_form_wfp3_modification" };
            lv.DataSource   = m;
            lv.DataBind();

            //lvAg_WFP3_Specifications"
            lv = pnlSubPanels.FindControl("lvAg_WFP3_Specifications") as ListView;
            var sp = from b in wDataContext.form_wfp3_specifications.Where(w => w.fk_form_wfp3 == PK_FormWfp3) select b;
            lv.DataKeyNames = new string[] { "pk_form_wfp3_specification" };
            lv.DataSource   = sp;
            lv.DataBind();

            //lvAg_WFP3_Techs
            lv = pnlSubPanels.FindControl("lvAg_WFP3_Techs") as ListView;
            var t = from b in wDataContext.form_wfp3_teches.Where(w => w.fk_form_wfp3 == PK_FormWfp3) select b;
            lv.DataKeyNames = new string[] { "pk_form_wfp3_tech" };
            lv.DataSource   = t;
            lv.DataBind();


            litAg_WFP3_Header.Text = WACGlobal_Methods.SpecialText_Agriculture_PopUpHeader(FK_FarmBusiness);
            string sWACRegion = WACGlobal_Methods.SpecialQuery_Agriculture_GetWACRegion_ByFarmBusinessPK(FK_FarmBusiness);

            Create_Agriculture_WFP3_Basic_Grid(PK_FormWfp3);
            Create_Agriculture_WFP3_Encumbrance_CurrentlyAssigned_Summary_Grid(PK_FormWfp3);
            Create_Agriculture_WFP3_Encumbrance_Possible_Summary_Grid(PK_FormWfp3);
            Create_Agriculture_WFP3_PaymentBMP_PaymentStatus_Grid(PK_FormWfp3);
            CreateAgWFP3PaymentBMPFundingOverviewGrid(PK_FormWfp3);

            if (fvAg_WFP3.CurrentMode == FormViewMode.ReadOnly && a.Count() == 1)
            {
                UpdatePanel up = (UpdatePanel)pnlAg_WFP3.FindControl("upAg_WFP3");
                Utility_WACUT_AttachedDocumentViewer docView = (Utility_WACUT_AttachedDocumentViewer)up.FindControl("WACUT_AttachedDocumentViewerWFP3");
                List <WACParameter> parms = new List <WACParameter>();
                parms.Add(new WACParameter("pk_farmBusiness", a.First().fk_farmBusiness, WACParameter.ParameterType.MasterKey));
                parms.Add(new WACParameter("pk_form_wfp2", a.First().pk_form_wfp3, WACParameter.ParameterType.PrimaryKey));
                docView.InitControl(parms);
            }

            if (fvAg_WFP3.CurrentMode == FormViewMode.Insert)
            {
                WACGlobal_Methods.PopulateControl_Generic_YesNoDDL(fvAg_WFP3, "ddlSpecialProvisions", "N");
                WACGlobal_Methods.PopulateControl_DatabaseLists_ProcurementType_DDL(fvAg_WFP3, "ddlProcurementType", "");
            }

            if (fvAg_WFP3.CurrentMode == FormViewMode.Edit)
            {
                WACGlobal_Methods.PopulateControl_Generic_YesNoDDL(fvAg_WFP3, "ddlSpecialProvisions", a.Single().specialProvisions);
                WACGlobal_Methods.PopulateControl_DatabaseLists_ProcurementType_DDL(fvAg_WFP3, "ddlProcurementType", a.Single().fk_procurementType_code);
            }
        }
    }