Exemplo n.º 1
0
        //public static Guid Save(DayCarePL.ChildFamilyProperties objChildFamily)
        //{
        //    DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clFamilyData, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT);
        //    clConnection.DoConnection();
        //    SqlConnection conn = clConnection.CreateConnection();
        //    SqlTransaction tran=null;
        //    Guid result = new Guid();
        //    bool FamilyResult = false;
        //    try
        //    {
        //DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clFamilyData, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT);
        //clConnection.OpenConnection(conn);
        //tran = conn.BeginTransaction();
        //SqlCommand cmd;
        //if (objChildFamily.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
        //{
        //    cmd = clConnection.CreateCommand("spAddChildFamily", conn);
        //    cmd.Parameters.Add(clConnection.GetInputParameter("@CreatedDateTime", DateTime.Now));
        //    cmd.Parameters.Add(clConnection.GetInputParameter("@CreatedById", objChildFamily.CreatedById));
        //}
        //else
        //{
        //    cmd = clConnection.CreateCommand("spUpdateChildFamily", conn);
        //    cmd.Parameters.Add(clConnection.GetInputParameter("@Id", objChildFamily.Id));
        //    //cmd.Parameters.Add(clConnection.GetInputParameter("@ChildFamilyId", objFamilyData.ChildFamilyId));
        //}
        ////ChildFamily
        //cmd.Transaction = tran;
        //cmd.Parameters.Add(clConnection.GetInputParameter("@SchoolId", objChildFamily.SchoolId));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@FamilyTitle", objChildFamily.FamilyTitle));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@UserName", objChildFamily.UserName));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@Password", objChildFamily.Password));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@Code", objChildFamily.Code));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@Address1", objChildFamily.Address1));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@Address2", objChildFamily.Address2));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@City", objChildFamily.City));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@StateId", objChildFamily.StateId));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@Zip", objChildFamily.Zip));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@HomePhone", objChildFamily.HomePhone));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@Comments", objChildFamily.Comments));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@MsgDisplayed", objChildFamily.MsgDisplayed));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@MsgStartDate", objChildFamily.MsgStartDate));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@MsgEndDate", objChildFamily.MsgEndDate));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@MsgActive", objChildFamily.MsgActive));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@LastModifiedDatetime", DateTime.Now));
        //cmd.Parameters.Add(clConnection.GetInputParameter("@LastModifiedById", objChildFamily.LastModifiedById));
        //cmd.Parameters.Add(clConnection.GetOutputParameter("@status", SqlDbType.Bit));
        //if (objChildFamily.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
        //{
        //    cmd.Parameters.Add(clConnection.GetOutputParameter("@Id", SqlDbType.UniqueIdentifier));
        //}
        //cmd.ExecuteNonQuery();

        //if (Convert.ToBoolean(cmd.Parameters["@status"].Value))
        //{
        //    if (objChildFamily.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
        //    {
        //        if (!cmd.Parameters["@Id"].Value.Equals(DayCarePL.Common.GUID_DEFAULT))
        //        {
        //            result = new Guid(cmd.Parameters["@Id"].Value.ToString());
        //        }
        //        else
        //        {
        //            result = new Guid(DayCarePL.Common.GUID_DEFAULT);
        //        }
        //    }
        //    else
        //    {
        //        result = objChildFamily.Id;
        //    }
        //}
        //else
        //{
        //    result = new Guid(DayCarePL.Common.GUID_DEFAULT);
        //}
        ////FamilyData
        //if (!result.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
        //{
        //    foreach (DayCarePL.FamilyDataProperties objFamilyData in objChildFamily.lstFamily)
        //    {
        //        if (objFamilyData.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
        //        {
        //            cmd = clConnection.CreateCommand("spAddFamilyData", conn);
        //            cmd.Parameters.Add(clConnection.GetInputParameter("@CreatedDateTime", DateTime.Now));
        //            cmd.Parameters.Add(clConnection.GetInputParameter("@CreatedById", objChildFamily.CreatedById));
        //        }
        //        else
        //        {
        //            cmd = clConnection.CreateCommand("spUpdateFamilyData", conn);
        //            cmd.Parameters.Add(clConnection.GetInputParameter("@Id", objFamilyData.Id));
        //        }
        //        cmd.Transaction = tran;
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@RelationShipId", objFamilyData.RelationShipId));
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@ChildFamilyId", result));
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@FirstName", objFamilyData.FirstName));
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@LastName", objFamilyData.LastName));
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@Phone1", objFamilyData.Phone1));
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@Phone1Type", objFamilyData.Phone1Type));
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@Phone2", objFamilyData.Phone2));
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@Phone2Type", objFamilyData.Phone2Type));
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@Email", objFamilyData.Email));
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@Photo", objFamilyData.Photo));
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@LastModifiedDatetime", DateTime.Now));
        //        cmd.Parameters.Add(clConnection.GetInputParameter("@LastModifiedById", objFamilyData.LastModifiedById));
        //        cmd.Parameters.Add(clConnection.GetOutputParameter("@status", SqlDbType.Bit));
        //        cmd.ExecuteNonQuery();
        //        if (!Convert.ToBoolean(cmd.Parameters["@status"].Value))
        //        {
        //            tran.Rollback();
        //            break;
        //        }
        //        else
        //        {
        //            FamilyResult = true;
        //        }
        //    }
        //    if (FamilyResult)
        //    {
        //        tran.Commit();
        //    }
        //    else
        //    {
        //        tran.Rollback();
        //    }
        //}
        //else
        //{
        //    tran.Rollback();
        //}
        //    }
        //    catch (Exception ex)
        //    {
        //        DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clFamilyData, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
        //        result = new Guid(DayCarePL.Common.GUID_DEFAULT);
        //        //if (tran != null)
        //        //{
        //        //    tran.Rollback();
        //        //}
        //    }
        //    finally
        //    {
        //        clConnection.CloseConnection(conn);
        //    }
        //    return result;
        //}
        #endregion

        #region Load Family Data By Id, Dt: 19-Aug-2011, DB: A"
        public static DayCarePL.FamilyDataProperties LoadFamilyDataById(Guid FamilyDataId, Guid SchoolId)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clFamilyData, "LoadFamilyDataById", "Execute LoadFamilyDataById Method", DayCarePL.Common.GUID_DEFAULT);
            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clFamilyData, "LoadFamilyDataById", "Debug LoadFamilyDataById Method", DayCarePL.Common.GUID_DEFAULT);
                DayCarePL.FamilyDataProperties objFamilyData = new DayCarePL.FamilyDataProperties();
                //SortedList sl = new SortedList();
                //sl.Add("@Id", FamilyDataId);
                //sl.Add("@SchoolId", SchoolId);
                //DataSet ds = clConnection.GetDataSet("spGetFamilyDatabyId", sl);
                //if (ds != null && ds.Tables.Count > 0)
                //{
                //    if (ds.Tables[0].Rows.Count > 0)
                //    {
                //        //Family Data
                //        objFamilyData.Id = new Guid(ds.Tables[0].Rows[0]["Id"].ToString());
                //        objFamilyData.RelationShipId = new Guid(ds.Tables[0].Rows[0]["RelationShipId"].ToString());
                //        objFamilyData.ChildFamilyId = new Guid(ds.Tables[0].Rows[0]["ChildFamilyId"].ToString());
                //        objFamilyData.FirstName = Convert.ToString(ds.Tables[0].Rows[0]["FirstName"]);
                //        objFamilyData.LastName = Convert.ToString(ds.Tables[0].Rows[0]["LastName"]);
                //        objFamilyData.Gender = Convert.ToBoolean(ds.Tables[0].Rows[0]["Gender"]);
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["IdInfo"].ToString()))
                //        {
                //            objFamilyData.IdInfo = Convert.ToString(ds.Tables[0].Rows[0]["IdInfo"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Address1"].ToString()))
                //        {
                //            objFamilyData.Address1 = Convert.ToString(ds.Tables[0].Rows[0]["Address1"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Address2"].ToString()))
                //        {
                //            objFamilyData.Address2 = Convert.ToString(ds.Tables[0].Rows[0]["Address2"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["City"].ToString()))
                //        {
                //            objFamilyData.City = Convert.ToString(ds.Tables[0].Rows[0]["City"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Zip"].ToString()))
                //        {
                //            objFamilyData.Zip = Convert.ToString(ds.Tables[0].Rows[0]["Zip"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["StateId"].ToString()))
                //        {
                //            objFamilyData.StateId = new Guid(ds.Tables[0].Rows[0]["StateId"].ToString());
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["CountryId"].ToString()))
                //        {
                //            objFamilyData.CountryId = new Guid(ds.Tables[0].Rows[0]["CountryId"].ToString());
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["MainPhone"].ToString()))
                //        {
                //            objFamilyData.MainPhone = Convert.ToString(ds.Tables[0].Rows[0]["MainPhone"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["SecondaryPhone"].ToString()))
                //        {
                //            objFamilyData.SecondaryPhone = Convert.ToString(ds.Tables[0].Rows[0]["SecondaryPhone"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Fax"].ToString()))
                //        {
                //            objFamilyData.Fax = Convert.ToString(ds.Tables[0].Rows[0]["Fax"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Email"].ToString()))
                //        {
                //            objFamilyData.Email = Convert.ToString(ds.Tables[0].Rows[0]["Email"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["UserName"].ToString()))
                //        {
                //            objFamilyData.UserName = Convert.ToString(ds.Tables[0].Rows[0]["UserName"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Password"].ToString()))
                //        {
                //            objFamilyData.Password = Convert.ToString(ds.Tables[0].Rows[0]["Password"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Photo"].ToString()))
                //        {
                //            objFamilyData.Photo = Convert.ToString(ds.Tables[0].Rows[0]["Photo"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["SecurityQuestion"].ToString()))
                //        {
                //            objFamilyData.SecurityQuestion = Convert.ToString(ds.Tables[0].Rows[0]["SecurityQuestion"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["SecurityAnswer"].ToString()))
                //        {
                //            objFamilyData.SecurityAnswer = Convert.ToString(ds.Tables[0].Rows[0]["SecurityAnswer"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Code"].ToString()))
                //        {
                //            objFamilyData.Code = Convert.ToString(ds.Tables[0].Rows[0]["Code"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Active"].ToString()))
                //        {
                //            objFamilyData.Active = Convert.ToBoolean(ds.Tables[0].Rows[0]["Active"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Comments"].ToString()))
                //        {
                //            objFamilyData.FamilyDataComments = Convert.ToString(ds.Tables[0].Rows[0]["Comments"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["CreatedDateTime"].ToString()))
                //        {
                //            objFamilyData.CreatedDateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["CreatedDateTime"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["CreatedById"].ToString()))
                //        {
                //            objFamilyData.CreatedById = new Guid(ds.Tables[0].Rows[0]["CreatedById"].ToString());
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["LastModifiedDatetime"].ToString()))
                //        {
                //            objFamilyData.LastModifiedDatetime = Convert.ToDateTime(ds.Tables[0].Rows[0]["LastModifiedDatetime"]);
                //        }
                //        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["LastModifiedById"].ToString()))
                //        {
                //            objFamilyData.LastModifiedById = new Guid(ds.Tables[0].Rows[0]["LastModifiedById"].ToString());
                //        }

                //        //Child Family
                //        //if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["SchoolId"].ToString()))
                //        //{
                //        //    objFamilyData.SchoolId = new Guid(ds.Tables[0].Rows[0]["SchoolId"].ToString());
                //        //}
                //        //if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Comments1"].ToString()))
                //        //{
                //        //    objFamilyData.ChildFamilyComments = Convert.ToString(ds.Tables[0].Rows[0]["Comments1"]);
                //        //}
                //        //if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["MsgDisplayed"].ToString()))
                //        //{
                //        //    objFamilyData.MsgDisplayed = Convert.ToString(ds.Tables[0].Rows[0]["MsgDisplayed"]);
                //        //}
                //        //if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["MsgStartDate"].ToString()))
                //        //{
                //        //    objFamilyData.MsgStartDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["MsgStartDate"]);
                //        //}
                //        //if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["MsgEndDate"].ToString()))
                //        //{
                //        //    objFamilyData.MsgEndDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["MsgEndDate"]);
                //        //}
                //        //if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["MsgActive"].ToString()))
                //        //{
                //        //    objFamilyData.MsgActive = Convert.ToBoolean(ds.Tables[0].Rows[0]["MsgActive"]);
                //        //}
                //    }
                //}

                return(objFamilyData);
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clFamilyData, "LoadFamilyDataById", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                return(null);
            }
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.FamilyInfo, "btnSave_Click", "Submit btnSave_Click called", DayCarePL.Common.GUID_DEFAULT);
            try
            {
                string err_msg = string.Empty;
                if (txtFirstNameGuardian1.Text.Trim() == "")
                {
                    err_msg = "- Please enter Guardian 1 First Name.\\n";
                }
                if (txtLastNameGuardian1.Text.Trim() == "")
                {
                    err_msg += "- Please enter Guardian 1 Last Name.";
                }
                if (err_msg.Length > 0)
                {
                    MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                    MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", err_msg, "false"));
                    return;
                }
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.FamilyInfo, "btnSave_Click", "Debug btnSave_Click ", DayCarePL.Common.GUID_DEFAULT);
                DayCareBAL.FamilyDataService    proxyFamilyData  = new DayCareBAL.FamilyDataService();
                DayCareBAL.ChildFamilyService   proxyChildFamily = new DayCareBAL.ChildFamilyService();
                DayCarePL.FamilyDataProperties  objFamilyData    = null;
                DayCarePL.ChildFamilyProperties objChildFamily   = new DayCarePL.ChildFamilyProperties();
                Guid ChildFamilyId;
                objChildFamily.SchoolId = GetSchoolId();
                txtPassword.Attributes.Add("value", txtPassword.Text);
                txtCode.Attributes.Add("value", txtCode.Text);
                if (!string.IsNullOrEmpty(txtUserName.Text.Trim()))
                {
                    if (!hdnName.Value.ToLower().Equals(txtUserName.Text.ToLower().Trim()))
                    {
                        bool result = proxyFamilyData.CheckDuplicateUserName(txtUserName.Text.Trim(), objChildFamily.SchoolId);
                        if (result)
                        {
                            MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                            MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "User Name Already Exist", "false"));
                            return;
                        }
                    }
                }

                bool IsCodeRequire = proxyFamilyData.CheckCodeRequire(objChildFamily.SchoolId);
                if (IsCodeRequire)
                {
                    if (string.IsNullOrEmpty(txtCode.Text.Trim()))
                    {
                        MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Please enter Passcode", "false"));
                        txtCode.Focus();
                        return;
                    }
                    else
                    {
                        //if (txtCode.Text.Length < 4)
                        //{
                        //    MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        //    MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Passcode require 4 digit number.", "false"));
                        //    return;
                        //}
                    }
                    //if (!txtCode.Text.Trim().Equals(hdnCode.Value))
                    //{
                    //    bool IsCodeDuplicate = proxyFamilyData.CheckDuplicateCode(txtCode.Text.Trim(), GetSchoolId());
                    //    if (IsCodeDuplicate)
                    //    {
                    //        MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                    //        MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Code Already Exist", "false"));
                    //        return;
                    //    }
                    //}
                }
                if (rdpMsgEndDate.SelectedDate != null)
                {
                    if (rdpMsgStartDate.SelectedDate == null)
                    {
                        MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Start date require", "false"));
                        return;
                    }
                }
                if (rdpMsgStartDate.SelectedDate != null && rdpMsgEndDate.SelectedDate != null)
                {
                    if (rdpMsgStartDate.SelectedDate > rdpMsgEndDate.SelectedDate)
                    {
                        MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Start date must be less than End date", "false"));
                        return;
                    }
                }

                if (fupImageGuardian1.HasFile)
                {
                    string   Extention = Path.GetExtension(fupImageGuardian1.FileName).ToLower();
                    string[] Ext       = { ".jpeg", ".jpg", ".png" };
                    if (Ext.ToList().FindAll(et => et.Equals(Extention)).Count == 0)
                    {
                        MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Please select .JPEG,.PNG file!", "false"));
                        return;
                    }
                }

                if (fupImageGuardian2.HasFile)
                {
                    string   Extention = Path.GetExtension(fupImageGuardian2.FileName).ToLower();
                    string[] Ext       = { ".jpeg", ".jpg", ".png" };
                    if (Ext.ToList().FindAll(et => et.Equals(Extention)).Count == 0)
                    {
                        MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Please select .JPEG,.PNG file!", "false"));
                        return;
                    }
                }
                string Guardian1FamilyId = "", Guardian2FamilyId = "";
                if (ViewState["ChildFamilyId"] != null)
                {
                    objChildFamily.Id = new Guid(ViewState["ChildFamilyId"].ToString());
                    Guardian1FamilyId = lblGuardian1FamilyId.Text;
                    Guardian2FamilyId = lblGuardian2FamilyId.Text;
                }
                else
                {
                    if (Session["StaffId"] != null)
                    {
                        objChildFamily.CreatedById = new Guid(Session["StaffId"].ToString());
                    }
                }


                //Child Family
                objChildFamily.FamilyTitle = txtLastNameGuardian1.Text + ", " + txtFirstNameGuardian1.Text;//txtFamilyTitle.Text.Trim();
                objChildFamily.UserName    = txtUserName.Text.Trim();
                objChildFamily.Password    = txtPassword.Text.Trim();
                objChildFamily.Code        = txtCode.Text.Trim();
                objChildFamily.Address1    = txtAddress1.Text.Trim();
                objChildFamily.Address2    = txtAddress2.Text.Trim();
                objChildFamily.City        = txtCity.Text.Trim();
                objChildFamily.Zip         = txtZip.Text.Trim();
                if (!ddlState.SelectedValue.Equals(DayCarePL.Common.GUID_DEFAULT))
                {
                    objChildFamily.StateId = new Guid(ddlState.SelectedValue);
                }
                objChildFamily.HomePhone = txtHomePhone.Text.Trim();
                objChildFamily.MsgActive = chkMsgActive.Checked;
                if (rdpMsgStartDate.SelectedDate != null)
                {
                    objChildFamily.MsgStartDate = rdpMsgStartDate.SelectedDate.Value;
                }
                if (rdpMsgEndDate.SelectedDate != null)
                {
                    objChildFamily.MsgEndDate = rdpMsgEndDate.SelectedDate.Value;
                }
                objChildFamily.MsgDisplayed = txtMessage.Text.Trim();
                objChildFamily.Comments     = txtComments.Text.Trim();
                objChildFamily.Active       = chkActive.Checked;
                if (Session["StaffId"] != null)
                {
                    objChildFamily.LastModifiedById = new Guid(Session["StaffId"].ToString());
                }

                objChildFamily.lstFamily = new List <DayCarePL.FamilyDataProperties>();

                //Family Data Guardian 1
                objFamilyData = new DayCarePL.FamilyDataProperties();
                if (!string.IsNullOrEmpty(Guardian1FamilyId))
                {
                    objFamilyData.Id = new Guid(Guardian1FamilyId);
                }
                objFamilyData.FirstName = txtFirstNameGuardian1.Text.Trim();
                objFamilyData.LastName  = txtLastNameGuardian1.Text.Trim();
                if (!ddlRelationshipGuardian1.SelectedValue.Equals(DayCarePL.Common.GUID_DEFAULT))
                {
                    objFamilyData.RelationShipId = new Guid(ddlRelationshipGuardian1.SelectedValue);
                }
                objFamilyData.Email = txtEmailGuardian1.Text.Trim();
                if (fupImageGuardian1.HasFile)
                {
                    objFamilyData.Photo = Path.GetExtension(fupImageGuardian1.FileName);
                }
                else
                {
                    if (!string.IsNullOrEmpty(lblImageGuardian1.Text))
                    {
                        objFamilyData.Photo = Path.GetExtension(lblImageGuardian1.Text);
                    }
                    else
                    {
                        objFamilyData.Photo = string.Empty;
                    }
                }
                if (!string.IsNullOrEmpty(txtPhone1Guardian1.Text.Trim()))
                {
                    objFamilyData.Phone1Type = ddlPhoneType1Guardian1.SelectedValue;
                    objFamilyData.Phone1     = txtPhone1Guardian1.Text.Trim();
                }
                if (!string.IsNullOrEmpty(txtPhone2Guardian1.Text.Trim()))
                {
                    objFamilyData.Phone2Type = ddPhoneType2Guardian1.SelectedValue;
                    objFamilyData.Phone2     = txtPhone2Guardian1.Text.Trim();
                }
                objFamilyData.GuardianIndex = 1;
                if (Session["StaffId"] != null)
                {
                    objFamilyData.LastModifiedById = new Guid(Session["StaffId"].ToString());
                }
                objChildFamily.lstFamily.Add(objFamilyData);

                //Family Data Guardian 2
                //if (!string.IsNullOrEmpty(txtFirstNameGuardian2.Text.Trim()) && !string.IsNullOrEmpty(txtEmailGuardian2.Text.Trim()) && ddlRelationshipGuardian2.SelectedIndex > 0 && !string.IsNullOrEmpty(txtLastNameGuardian2.Text.Trim()))
                if (!string.IsNullOrEmpty(txtFirstNameGuardian2.Text.Trim()) && !string.IsNullOrEmpty(txtLastNameGuardian2.Text.Trim()))
                {
                    objFamilyData = new DayCarePL.FamilyDataProperties();
                    if (!string.IsNullOrEmpty(Guardian2FamilyId))
                    {
                        objFamilyData.Id = new Guid(Guardian2FamilyId);
                    }
                    objFamilyData.FirstName = txtFirstNameGuardian2.Text.Trim();
                    objFamilyData.LastName  = txtLastNameGuardian2.Text.Trim();
                    if (!ddlRelationshipGuardian2.SelectedValue.Equals(DayCarePL.Common.GUID_DEFAULT))
                    {
                        objFamilyData.RelationShipId = new Guid(ddlRelationshipGuardian2.SelectedValue);
                    }
                    objFamilyData.Email = txtEmailGuardian2.Text.Trim();
                    if (fupImageGuardian1.HasFile)
                    {
                        objFamilyData.Photo = Path.GetExtension(fupImageGuardian2.FileName);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(lblImageGuardian2.Text))
                        {
                            objFamilyData.Photo = Path.GetExtension(lblImageGuardian2.Text);
                        }
                        else
                        {
                            objFamilyData.Photo = string.Empty;
                        }
                    }
                    if (!string.IsNullOrEmpty(txtPhone1Guardian2.Text.Trim()))
                    {
                        objFamilyData.Phone1Type = ddlPhoneType1Guardian2.SelectedValue;
                        objFamilyData.Phone1     = txtPhone1Guardian2.Text.Trim();
                    }
                    if (!string.IsNullOrEmpty(txtPhone2Guardian2.Text.Trim()))
                    {
                        objFamilyData.Phone2Type = ddlPhoneType2Guardian2.SelectedValue;
                        objFamilyData.Phone2     = txtPhone2Guardian2.Text.Trim();
                    }
                    objFamilyData.GuardianIndex = 2;
                    if (Session["StaffId"] != null)
                    {
                        objFamilyData.LastModifiedById = new Guid(Session["StaffId"].ToString());
                    }
                    objChildFamily.lstFamily.Add(objFamilyData);
                }
                else
                {
                    string ErrorMsg = "";
                    if (!string.IsNullOrEmpty(txtFirstNameGuardian2.Text.Trim()))
                    {
                        if (string.IsNullOrEmpty(txtLastNameGuardian2.Text.Trim()))
                        {
                            ErrorMsg = "- Please enter Guardian 2 Last Name\\n";
                            //MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                            //MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Please enter Guardian 2 Last Name", "false"));
                            //return;
                        }
                        //if (ddlRelationshipGuardian2.SelectedIndex == 0)
                        //{
                        //    ErrorMsg += "- Please enter Guardian 2 Relationship\\n";
                        //    //MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        //    //MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Please enter Guardian 2 Relationship", "false"));
                        //    //return;
                        //}
                        //if (string.IsNullOrEmpty(txtEmailGuardian2.Text))
                        //{
                        //    ErrorMsg += "- Please enter Guardian 2 Email\\n";

                        //}
                        if (!string.IsNullOrEmpty(ErrorMsg))
                        {
                            MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                            MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", ErrorMsg, "false"));
                            return;
                        }
                    }
                }

                objChildFamily.SchoolYearId = new Guid(Session["CurrentSchoolYearId"].ToString());
                ChildFamilyId = proxyChildFamily.Save(objChildFamily);
                if (!ChildFamilyId.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
                {
                    if (fupImageGuardian1.HasFile)
                    {
                        fupImageGuardian1.SaveAs(Server.MapPath("~/FamilyImages/" + ChildFamilyId + "_1" + Path.GetExtension(fupImageGuardian1.FileName)));
                    }
                    if (fupImageGuardian2.HasFile)
                    {
                        fupImageGuardian2.SaveAs(Server.MapPath("~/FamilyImages/" + ChildFamilyId + "_2" + Path.GetExtension(fupImageGuardian2.FileName)));
                    }
                    MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                    MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Saved Successfully", "false"));

                    if (ViewState["ChildFamilyId"] == null)
                    {
                        Session["FamilyInfoMessage"] = true;
                        Response.Redirect("FamilyInfo.aspx?ChildFamilyId=" + ChildFamilyId + "", false);
                    }
                    else
                    {
                        rgChildData.Rebind();
                        LoadFamilyData(new Guid(ViewState["ChildFamilyId"].ToString()));
                    }
                    //else
                    //{
                    //    Response.Redirect("ChildFamily.aspx", false);
                    //}
                }
                else
                {
                    MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                    MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Internal Error,Please try again", "false"));
                    return;
                }
            }

            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.FamilyInfo, "btnSave_Click", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Internal Error,Please try again", "false"));
                return;
            }
        }
Exemplo n.º 3
0
        protected void rgFamilyData_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            //if (e.Item.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem || e.Item.ItemType == Telerik.Web.UI.GridItemType.Item)
            //{
            //    GridDataItem dataItem = e.Item as GridDataItem;
            //    Label
            //}
            if (e.Item.ItemType == GridItemType.AlternatingItem || e.Item.ItemType == GridItemType.Item)
            {
                DayCarePL.FamilyDataProperties objFamilyData = e.Item.DataItem as DayCarePL.FamilyDataProperties;
                Image imgStaff = e.Item.FindControl("imgFamilyData") as Image;
                if (!string.IsNullOrEmpty(objFamilyData.Photo))
                {
                    imgStaff.ImageUrl = "../FamilyImages/" + objFamilyData.Photo;
                }
                else
                {
                    //if (objFamilyData.Gender == true)//true= Male
                    //{
                    //    imgStaff.ImageUrl = "../FamilyImages/male_photo.png";
                    //}
                    //else
                    //{
                    //    imgStaff.ImageUrl = "../FamilyImages/female_photo.png";
                    //}
                }
                HyperLink hlChildData = e.Item.FindControl("hlChildData") as HyperLink;
                if (hlChildData != null)
                {
                    hlChildData.NavigateUrl = "ChildData.aspx?Id=" + objFamilyData.ChildFamilyId;
                }
                if (Session["SchoolId"] != null)
                {
                    SchoolId = new Guid(Session["SchoolId"].ToString());
                }
                // Guid CurrentSchoolYearId = new Guid();
                if (Session["CurrentSchoolYearId"] != null)
                {
                    CurrentSchoolYearId = new Guid(Session["CurrentSchoolYearId"].ToString());
                }
                if (!Common.IsCurrentYear(CurrentSchoolYearId, SchoolId))
                {
                    hlChildData.Enabled = false;
                }
                //Guid SchoolId = new Guid();
                //Guid CurrentSchoolYearId = new Guid();
                //if (Session["SchoolId"] != null)
                //{
                //    SchoolId = new Guid(Session["SchoolId"].ToString());
                //}

                //if (Session["CurrentSchoolYearId"] != null)
                //{
                //    CurrentSchoolYearId = new Guid(Session["CurrentSchoolYearId"].ToString());
                //}

                //if (!Common.IsCurrentYear(CurrentSchoolYearId, SchoolId))
                //{
                //    GridDataItem itm = (GridDataItem)e.Item;
                //    if (itm != null)
                //    {
                //        ImageButton imgbtnEdit = (ImageButton)itm["Edit"].Controls[0];
                //        if (imgbtnEdit != null)
                //        {
                //            imgbtnEdit.ToolTip = "";
                //            imgbtnEdit.Enabled = false;
                //            imgbtnEdit.Style.Value = "cursor:auto";
                //        }
                //        GridCommandItem cmdItem = itm.OwnerTableView.GetItems(GridItemType.CommandItem)[0] as GridCommandItem;
                //        if (cmdItem != null)
                //        {
                //            LinkButton lnkbtnInitInsertButton = (LinkButton)cmdItem.FindControl("InitInsertButton");
                //            lnkbtnInitInsertButton.Enabled = false;
                //            lnkbtnInitInsertButton.Style.Value = "cursor:auto";
                //        }
                //        //rgStaffList.MasterTableView.IsItemInserted = false;
                //    }
                //}
            }
        }
Exemplo n.º 4
0
        public static DayCarePL.ChildFamilyProperties LoadChildFamilyById(Guid Id, Guid CurrentSchoolyearId)
        {
            clConnection.DoConnection();
            DayCareDataContext db = new DayCareDataContext();

            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clChildFamily, "LoadChildFamilyById", "Execute LoadChildFamilyById Method", DayCarePL.Common.GUID_DEFAULT);
            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clChildFamily, "LoadChildFamilyById", "Debug LoadChildFamilyById Method", DayCarePL.Common.GUID_DEFAULT);
                DayCarePL.ChildFamilyProperties objChildFamilyId = null;
                SortedList sl = new SortedList();
                sl.Add("@Id", Id);
                sl.Add("@CurrentSchoolyearId", CurrentSchoolyearId);
                objChildFamilyId           = new DayCarePL.ChildFamilyProperties();
                objChildFamilyId.lstFamily = new List <DayCarePL.FamilyDataProperties>();
                DayCarePL.FamilyDataProperties objFamilyData;
                var data = db.spGetChildFamilyById(Id, CurrentSchoolyearId);

                foreach (var d in data)
                {
                    if (objChildFamilyId.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
                    {
                        objChildFamilyId.Id                   = d.ChildFamilyId;
                        objChildFamilyId.SchoolId             = d.SchoolId;
                        objChildFamilyId.FamilyTitle          = d.FamilyTitle;
                        objChildFamilyId.UserName             = d.UserName;
                        objChildFamilyId.Password             = d.Password;
                        objChildFamilyId.Code                 = d.Code;
                        objChildFamilyId.Address1             = d.Address1;
                        objChildFamilyId.Address2             = d.Address2;
                        objChildFamilyId.City                 = d.City;
                        objChildFamilyId.StateId              = d.StateId;
                        objChildFamilyId.Zip                  = d.Zip;
                        objChildFamilyId.HomePhone            = d.HomePhone;
                        objChildFamilyId.Comments             = d.Comments;
                        objChildFamilyId.Active               = d.Active;
                        objChildFamilyId.MsgDisplayed         = d.MsgDisplayed;
                        objChildFamilyId.MsgStartDate         = d.MsgStartDate;
                        objChildFamilyId.MsgEndDate           = d.MsgEndDate;
                        objChildFamilyId.MsgActive            = d.MsgActive;
                        objChildFamilyId.CreatedById          = d.ChildFamilyCreatedById;
                        objChildFamilyId.CreatedDateTime      = d.ChildFamilyCreateDateTime;
                        objChildFamilyId.LastModifiedById     = d.ChildFamilyLastModifiedById;
                        objChildFamilyId.LastModifiedDatetime = d.ChildFamilyLastModifiedDateTime;
                    }
                    objFamilyData                      = new DayCarePL.FamilyDataProperties();
                    objFamilyData.Id                   = d.FamilyDataId;
                    objFamilyData.RelationShipId       = d.RelationShipId;
                    objFamilyData.FirstName            = d.FamilyFirstName;
                    objFamilyData.LastName             = d.FamilyLastName;
                    objFamilyData.Email                = d.Email;
                    objFamilyData.Phone1Type           = d.FamilyPhone1Type;
                    objFamilyData.Phone1               = d.FamilyPhone1;
                    objFamilyData.Phone2Type           = d.FamilyPhone2Type;
                    objFamilyData.Phone2               = d.FamilyPhone2;
                    objFamilyData.Photo                = d.Photo;
                    objFamilyData.GuardianIndex        = d.Guardian;
                    objFamilyData.CreatedById          = d.FamilyCreatedById;
                    objFamilyData.CreatedDateTime      = d.FamilyCreateDateTime;
                    objFamilyData.LastModifiedById     = d.FamilyLastModifiedById;
                    objFamilyData.LastModifiedDatetime = d.FamilyLastModifiedDateTime;
                    objChildFamilyId.lstFamily.Add(objFamilyData);
                }
                return(objChildFamilyId);
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clChildFamily, "LoadChildFamilyById", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                return(null);
            }
        }