Esempio n. 1
0
        protected void rgFamilyPayment_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.AlternatingItem || e.Item.ItemType == GridItemType.Item)
            {
                DayCarePL.FamilyPaymentProperties objFamilyPayment = e.Item.DataItem as DayCarePL.FamilyPaymentProperties;
                if (objFamilyPayment != null)
                {
                    Label lblPaymentMethod = e.Item.FindControl("lblPaymentMethod") as Label;
                    if (!string.IsNullOrEmpty(objFamilyPayment.PaymentMethod))
                    {
                        string paymentmethod = "";
                        switch (objFamilyPayment.PaymentMethod)
                        {
                        case "0":
                            paymentmethod = "Cash";
                            break;

                        case "1":
                            paymentmethod = "Check";
                            break;

                        case "2":
                            paymentmethod = "Credit";
                            break;
                        }
                        lblPaymentMethod.Text = paymentmethod;
                    }
                }
            }
            if (e.Item.ItemType == GridItemType.EditItem)
            {
                GridEditableItem itm = e.Item as GridEditableItem;
                DayCarePL.FamilyPaymentProperties objFamilyPayment = e.Item.DataItem as DayCarePL.FamilyPaymentProperties;
                RadDatePicker rdpPostDate      = e.Item.FindControl("rdpPostDate") as RadDatePicker;
                DropDownList  ddlPaymentMethod = e.Item.FindControl("ddlPaymentMethod") as DropDownList;
                if (objFamilyPayment != null)
                {
                    if (objFamilyPayment.PostDate != null)
                    {
                        rdpPostDate.SelectedDate = objFamilyPayment.PostDate;
                    }
                    ddlPaymentMethod.SelectedValue = objFamilyPayment.PaymentMethod;
                }
            }
        }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.SchoolYear, "SubmitRecord", "Submit record method called", DayCarePL.Common.GUID_DEFAULT);
            bool   result = false;
            string Amount = "";

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.SchoolYear, "SubmitRecord", "Debug Submit Record Of SchoolYear", DayCarePL.Common.GUID_DEFAULT);
                DayCareBAL.FamilyPaymentService          proxyFamilyPayment = new DayCareBAL.FamilyPaymentService();
                DayCarePL.FamilyPaymentProperties        objFamilyPayment   = new DayCarePL.FamilyPaymentProperties();
                List <DayCarePL.FamilyPaymentProperties> lstFamilyPayment   = new List <DayCarePL.FamilyPaymentProperties>();

                foreach (GridDataItem e1 in rgFamilyPayment.Items)
                {
                    TextBox       txtAmount        = e1.FindControl("txtAmount") as TextBox;
                    RadDatePicker rdpPostDate      = e1.FindControl("rdpPostDate") as RadDatePicker;
                    DropDownList  ddlPaymentMethod = e1.FindControl("ddlPaymentMethod") as DropDownList;
                    TextBox       txtPaymentDetail = e1.FindControl("txtPaymentDetail") as TextBox;
                    if (txtAmount != null && rdpPostDate != null && ddlPaymentMethod != null && txtPaymentDetail != null && rdpPostDate.SelectedDate != null && !string.IsNullOrEmpty(txtAmount.Text) && ddlPaymentMethod.SelectedIndex > 0)
                    {
                        objFamilyPayment = new DayCarePL.FamilyPaymentProperties();
                        if ((e1.FindControl("rdpPostDate") as RadDatePicker).SelectedDate != null)
                        {
                            objFamilyPayment.PostDate = (e1.FindControl("rdpPostDate") as RadDatePicker).SelectedDate.Value;
                        }
                        else
                        {
                            objFamilyPayment.PostDate = null;
                        }

                        objFamilyPayment.PaymentMethod = (e1.FindControl("ddlPaymentMethod") as DropDownList).SelectedValue;

                        objFamilyPayment.PaymentDetail = (e1.FindControl("txtPaymentDetail") as TextBox).Text;


                        if (!string.IsNullOrEmpty((e1.FindControl("txtAmount") as TextBox).Text))
                        {
                            Amount = (e1.FindControl("txtAmount") as TextBox).Text;
                        }

                        objFamilyPayment.ChildFamilyId = new Guid((e1.FindControl("lblChildFamilyId") as Label).Text);

                        decimal amountresult = 0;
                        if (!string.IsNullOrEmpty(Amount))
                        {
                            decimal.TryParse(Amount, out amountresult);
                            if (amountresult == 0)
                            {
                                //objFamilyPayment.Amount = amountresult;
                                //MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                                //MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Pease enter valid Amount.", "false"));
                                //return;
                            }
                            else
                            {
                                objFamilyPayment.Amount = amountresult;
                            }
                        }
                        if (Session["CurrentSchoolYearId"] != null)
                        {
                            objFamilyPayment.SchoolYearId = new Guid(Session["CurrentSchoolYearId"].ToString());
                        }
                        //if (e.CommandName != "PerformInsert")
                        //{
                        if (Session["StaffId"] != null)
                        {
                            objFamilyPayment.CreatedById      = new Guid(Session["StaffId"].ToString());
                            objFamilyPayment.LastModifiedById = new Guid(Session["StaffId"].ToString());
                        }

                        hdnName.Value = "";
                        if (amountresult != 0)
                        {
                            lstFamilyPayment.Add(objFamilyPayment);
                        }
                    }
                }
                if (lstFamilyPayment.Count > 0)
                {
                    if (proxyFamilyPayment.Save(lstFamilyPayment))
                    {
                        btnSave.Enabled = true;
                        btnSave.Attributes.Add("display", "block");
                        MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Saved Successfully\\nEntries are posted to Ledger", "false"));
                        ViewState["IsPreRenderCall"] = null;
                        rgFamilyPayment.MasterTableView.Rebind();
                    }
                }
                else
                {
                    btnSave.Enabled = true;
                    btnSave.Attributes.Add("display", "block");
                    MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                    MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Please enter valid details at least a family", "false"));
                }
            }
            catch (Exception ex)
            {
                btnSave.Enabled = true;
                btnSave.Attributes.Remove("disabled");
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.SchoolYear, "SubmitRecord", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
        }
Esempio n. 3
0
        public bool SubmitRecord(object sender, GridCommandEventArgs e)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.SchoolYear, "SubmitRecord", "Submit record method called", DayCarePL.Common.GUID_DEFAULT);
            bool   result = false;
            string Amount = "";

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.SchoolYear, "SubmitRecord", "Debug Submit Record Of SchoolYear", DayCarePL.Common.GUID_DEFAULT);
                DayCareBAL.FamilyPaymentService   proxyFamilyPayment = new DayCareBAL.FamilyPaymentService();
                DayCarePL.FamilyPaymentProperties objFamilyPayment   = new DayCarePL.FamilyPaymentProperties();

                foreach (GridDataItem e1 in rgFamilyPayment.Items)
                {
                    if ((e.Item.FindControl("rdpPostDate") as RadDatePicker).SelectedDate != null)
                    {
                        objFamilyPayment.PostDate = (e1.FindControl("rdpPostDate") as RadDatePicker).SelectedDate.Value;
                    }
                    else
                    {
                        objFamilyPayment.PostDate = null;
                    }

                    objFamilyPayment.PaymentMethod = (e1.FindControl("ddlPaymentMethod") as DropDownList).SelectedValue;

                    objFamilyPayment.PaymentDetail = (e1.FindControl("txtPaymentDetail") as TextBox).Text;


                    if (!string.IsNullOrEmpty((e.Item.FindControl("txtAmount") as TextBox).Text))
                    {
                        Amount = (e1.FindControl("txtAmount") as TextBox).Text;
                    }

                    objFamilyPayment.ChildFamilyId = new Guid((e1.FindControl("txtChildFamilyId") as Label).Text);


                    if (!string.IsNullOrEmpty(Amount))
                    {
                        decimal amountresult = 0;
                        decimal.TryParse(Amount, out amountresult);
                        if (amountresult == 0)
                        {
                            objFamilyPayment.Amount = amountresult;
                            MasterAjaxManager       = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                            MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Pease enter valid Amount.", "false"));
                            return(false);
                        }
                        else
                        {
                            objFamilyPayment.Amount = amountresult;
                        }
                    }
                    if (Session["CurrentSchoolYearId"] != null)
                    {
                        objFamilyPayment.SchoolYearId = new Guid(Session["CurrentSchoolYearId"].ToString());
                    }
                    //if (e.CommandName != "PerformInsert")
                    //{
                    if (Session["StaffId"] != null)
                    {
                        objFamilyPayment.CreatedById      = new Guid(Session["StaffId"].ToString());
                        objFamilyPayment.LastModifiedById = new Guid(Session["StaffId"].ToString());
                    }

                    hdnName.Value = "";
                }
                //if (proxyFamilyPayment.Save(objFamilyPayment))
                //{
                //    MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                //    MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Saved Successfully", "false"));
                //    result = true;
                //    ViewState["IsPreRenderCall"] = null;
                //}
                //else
                //{
                //    result = false;
                //}
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.SchoolYear, "SubmitRecord", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
            return(result);
        }