Example #1
0
    private void RepeaterFill()
    {
        MST_HospitalBAL balMST_Hospital = new MST_HospitalBAL();

        rptHospitalList.DataSource = balMST_Hospital.SelectAll();
        rptHospitalList.DataBind();
        int Count = rptHospitalList.Items.Count;

        lblCount.Text = Count.ToString();
    }
Example #2
0
 protected void rptHospitalList_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "DeleteRecord" && e.CommandArgument != null)
     {
         try
         {
             MST_HospitalBAL balMST_Hospital = new MST_HospitalBAL();
             balMST_Hospital.Delete(Convert.ToInt32(e.CommandArgument));
         }
         catch (Exception ex)
         {
             pnlAlert.Visible = true;
             lblMsg.Text      = ex.Message;
         }
         finally
         {
             RepeaterFill();
         }
     }
 }
    private void FillControls(Int32 HospitalID)
    {
        //lblPageHeader.Text = CV.PageHeaderEdit + " Hospital";

        MST_HospitalBAL balMST_Hospital = new MST_HospitalBAL();
        MST_HospitalENT entMST_Hospital = new MST_HospitalENT();

        entMST_Hospital = balMST_Hospital.SelectPK(HospitalID);

        if (!entMST_Hospital.HospitalName.IsNull)
        {
            txtHospitalName.Text = entMST_Hospital.HospitalName.Value.ToString();
        }

        if (!entMST_Hospital.CityID.IsNull)
        {
            ddlCity.SelectedValue = entMST_Hospital.CityID.Value.ToString();
        }

        if (!entMST_Hospital.CategoryID.IsNull)
        {
            ddlCategory.SelectedValue = entMST_Hospital.CategoryID.Value.ToString();
        }

        if (!entMST_Hospital.CategoryTypeID.IsNull)
        {
            ddlCategoryType.SelectedValue = entMST_Hospital.CategoryTypeID.Value.ToString();
        }

        if (!entMST_Hospital.Address.IsNull)
        {
            txtAddress.Text = entMST_Hospital.Address.Value.ToString();
        }

        if (!entMST_Hospital.MobileNumber.IsNull)
        {
            txtMobileNumber.Text = entMST_Hospital.MobileNumber.Value.ToString();
        }

        if (!entMST_Hospital.TelePhoneNumber.IsNull)
        {
            txtTelePhoneNumber.Text = entMST_Hospital.TelePhoneNumber.Value.ToString();
        }

        if (!entMST_Hospital.Fax.IsNull)
        {
            txtFax.Text = entMST_Hospital.Fax.Value.ToString();
        }

        if (!entMST_Hospital.Website.IsNull)
        {
            txtWebsite.Text = entMST_Hospital.Website.Value.ToString();
        }

        if (!entMST_Hospital.EmailID.IsNull)
        {
            txtEmailAddress.Text = entMST_Hospital.EmailID.Value.ToString();
        }

        if (!entMST_Hospital.AmbulancePhoneNumber.IsNull)
        {
            txtAmbulancePhoneNumber.Text = entMST_Hospital.AmbulancePhoneNumber.Value.ToString();
        }

        if (!entMST_Hospital.EmergencyNumber.IsNull)
        {
            txtEmergencyNumber.Text = entMST_Hospital.EmergencyNumber.Value.ToString();
        }

        if (!entMST_Hospital.HospitalImage.IsNull)
        {
            imgHospitalImage.ImageUrl = entMST_Hospital.HospitalImage.Value.ToString();
            imgHospitalImage.Visible  = true;
        }

        if (!entMST_Hospital.LocationCoordinates.IsNull)
        {
            txtLocationCoordinates.Text = entMST_Hospital.LocationCoordinates.Value.ToString();
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["HospitalID"] == null)
        {
            MST_HospitalENT entMST_Hospital = new MST_HospitalENT();

            if (txtHospitalName.Text.ToString().Trim() != "")
            {
                entMST_Hospital.HospitalName = txtHospitalName.Text.ToString().Trim();
            }
            if (ddlCity.SelectedIndex > 0)
            {
                entMST_Hospital.CityID = Convert.ToInt32(ddlCity.SelectedValue);
            }
            if (ddlCategory.SelectedIndex > 0)
            {
                entMST_Hospital.CategoryID = Convert.ToInt32(ddlCategory.SelectedValue);
            }
            if (ddlCategoryType.SelectedIndex > 0)
            {
                entMST_Hospital.CategoryTypeID = Convert.ToInt32(ddlCategoryType.SelectedValue);
            }
            if (txtAddress.Text.ToString().Trim() != "")
            {
                entMST_Hospital.Address = txtAddress.Text.ToString().Trim();
            }
            if (txtMobileNumber.Text.ToString().Trim() != "")
            {
                entMST_Hospital.MobileNumber = txtMobileNumber.Text.ToString().Trim();
            }
            if (txtTelePhoneNumber.Text.ToString().Trim() != "")
            {
                entMST_Hospital.TelePhoneNumber = txtTelePhoneNumber.Text.ToString().Trim();
            }
            if (txtFax.Text.ToString().Trim() != "")
            {
                entMST_Hospital.Fax = txtFax.Text.ToString().Trim();
            }
            if (txtWebsite.Text.ToString().Trim() != "")
            {
                entMST_Hospital.Website = txtWebsite.Text.ToString().Trim();
            }
            if (txtEmailAddress.Text.ToString().Trim() != "")
            {
                entMST_Hospital.EmailID = txtEmailAddress.Text.ToString().Trim();
            }
            if (txtAmbulancePhoneNumber.Text.ToString().Trim() != "")
            {
                entMST_Hospital.AmbulancePhoneNumber = txtAmbulancePhoneNumber.Text.ToString().Trim();
            }
            if (txtEmergencyNumber.Text.ToString().Trim() != "")
            {
                entMST_Hospital.EmergencyNumber = txtEmergencyNumber.Text.ToString().Trim();
            }
            if (txtLocationCoordinates.Text.ToString().Trim() != "")
            {
                entMST_Hospital.LocationCoordinates = txtLocationCoordinates.Text.ToString().Trim();
            }
            string strImagePath = "~/HospitalImage/";
            if (fuHospitalImage.HasFile)
            {
                entMST_Hospital.HospitalImage = strImagePath + fuHospitalImage.FileName;
            }
            else
            {
                entMST_Hospital.HospitalImage = imgHospitalImage.ImageUrl;
            }

            #region Upload Image
            if (fuHospitalImage.HasFile)
            {
                if (CommonFunctions.IsValidPhoto(fuHospitalImage, fuHospitalImage.FileName) == String.Empty)
                {
                    if (!CommonFunctions.UploadDocument(fuHospitalImage, Server.MapPath(strImagePath), Server.MapPath(strImagePath + fuHospitalImage.FileName), Server.MapPath(strImagePath + fuHospitalImage.FileName)))
                    {
                        lblMessage.Text = "Kindly Select a Image to Upload";
                    }
                }
                else
                {
                    lblMessage.Text = CommonFunctions.IsValidPhoto(fuHospitalImage, fuHospitalImage.FileName);
                    return;
                }
            }
            #endregion Upload Image

            entMST_Hospital.CreationDate = DateTime.Now;

            entMST_Hospital.ModificationDate = DateTime.Now;

            entMST_Hospital.UserID = Convert.ToInt32(Session["UserID"]);

            MST_HospitalBAL balMST_Hospital = new MST_HospitalBAL();

            if (balMST_Hospital.Insert(entMST_Hospital))
            {
                pnlAlert.Visible = true;
                lblMessage.Text  = "Data Inserted Successfully.";
                ClearControls();
            }
        }
        else
        {
            MST_HospitalENT entMST_Hospital = new MST_HospitalENT();

            if (txtHospitalName.Text.ToString().Trim() != "")
            {
                entMST_Hospital.HospitalName = txtHospitalName.Text.ToString().Trim();
            }
            if (ddlCity.SelectedIndex > 0)
            {
                entMST_Hospital.CityID = Convert.ToInt32(ddlCity.SelectedValue);
            }
            if (ddlCategory.SelectedIndex > 0)
            {
                entMST_Hospital.CategoryID = Convert.ToInt32(ddlCategory.SelectedValue);
            }
            if (ddlCategoryType.SelectedIndex > 0)
            {
                entMST_Hospital.CategoryTypeID = Convert.ToInt32(ddlCategoryType.SelectedValue);
            }
            if (txtAddress.Text.ToString().Trim() != "")
            {
                entMST_Hospital.Address = txtAddress.Text.ToString().Trim();
            }
            if (txtMobileNumber.Text.ToString().Trim() != "")
            {
                entMST_Hospital.MobileNumber = txtMobileNumber.Text.ToString().Trim();
            }
            if (txtTelePhoneNumber.Text.ToString().Trim() != "")
            {
                entMST_Hospital.TelePhoneNumber = txtTelePhoneNumber.Text.ToString().Trim();
            }
            if (txtFax.Text.ToString().Trim() != "")
            {
                entMST_Hospital.Fax = txtFax.Text.ToString().Trim();
            }
            if (txtWebsite.Text.ToString().Trim() != "")
            {
                entMST_Hospital.Website = txtWebsite.Text.ToString().Trim();
            }
            if (txtEmailAddress.Text.ToString().Trim() != "")
            {
                entMST_Hospital.EmailID = txtEmailAddress.Text.ToString().Trim();
            }
            if (txtAmbulancePhoneNumber.Text.ToString().Trim() != "")
            {
                entMST_Hospital.AmbulancePhoneNumber = txtAmbulancePhoneNumber.Text.ToString().Trim();
            }
            if (txtEmergencyNumber.Text.ToString().Trim() != "")
            {
                entMST_Hospital.EmergencyNumber = txtEmergencyNumber.Text.ToString().Trim();
            }
            if (txtLocationCoordinates.Text.ToString().Trim() != "")
            {
                entMST_Hospital.LocationCoordinates = txtLocationCoordinates.Text.ToString().Trim();
            }
            if (fuHospitalImage.FileName.ToString().Trim() != "")
            {
                imgHospitalImage.Visible      = true;
                entMST_Hospital.HospitalImage = fuHospitalImage.FileName.ToString().Trim();
            }

            string strImagePath = "~/HospitalImage/";
            if (fuHospitalImage.HasFile)
            {
                entMST_Hospital.HospitalImage = strImagePath + fuHospitalImage.FileName;
            }
            else
            {
                entMST_Hospital.HospitalImage = imgHospitalImage.ImageUrl;
            }
            #region Upload Image
            if (fuHospitalImage.HasFile)
            {
                if (CommonFunctions.IsValidPhoto(fuHospitalImage, fuHospitalImage.FileName) == String.Empty)
                {
                    if (!CommonFunctions.UploadDocument(fuHospitalImage, Server.MapPath(strImagePath), Server.MapPath(strImagePath + fuHospitalImage.FileName), Server.MapPath(strImagePath + fuHospitalImage.FileName)))
                    {
                        lblMessage.Text = "Kindly Select a Image to Upload";
                    }
                }
                else
                {
                    lblMessage.Text = CommonFunctions.IsValidPhoto(fuHospitalImage, fuHospitalImage.FileName);
                    return;
                }
            }
            #endregion Upload Image

            entMST_Hospital.HospitalID = Convert.ToInt32(Request.QueryString["HospitalID"]);

            entMST_Hospital.ModificationDate = DateTime.Now;

            entMST_Hospital.UserID = Convert.ToInt32(Session["UserID"]);

            MST_HospitalBAL balMST_Hospital = new MST_HospitalBAL();

            if (balMST_Hospital.Update(entMST_Hospital))
            {
                Response.Redirect("~/AdminPanel/Master/MST_Hospital/MST_HospitalList.aspx");
            }
        }
    }