Beispiel #1
0
        public static bool Save(DayCarePL.FeesPeriodProperties objFeesPeriod)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clFeesPeriod, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT);
            clConnection.DoConnection();
            bool result                     = false;
            DayCareDataContext db           = new DayCareDataContext();
            FeesPeriod         DBFeesPeriod = null;

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clFeesPeriod, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT);
                if (objFeesPeriod.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
                {
                    DBFeesPeriod    = new FeesPeriod();
                    DBFeesPeriod.Id = System.Guid.NewGuid();
                    DBFeesPeriod.CreatedDateTime = DateTime.Now;
                    DBFeesPeriod.CreatedById     = objFeesPeriod.CreatedById;
                }
                else
                {
                    DBFeesPeriod = db.FeesPeriods.SingleOrDefault(F => F.Id.Equals(objFeesPeriod.Id));
                }
                DBFeesPeriod.LastModifiedById     = objFeesPeriod.LastModifiedById;
                DBFeesPeriod.LastModifiedDatetime = DateTime.Now;
                DBFeesPeriod.Name   = objFeesPeriod.Name;
                DBFeesPeriod.Active = objFeesPeriod.Active;
                if (objFeesPeriod.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
                {
                    db.FeesPeriods.InsertOnSubmit(DBFeesPeriod);
                }
                db.SubmitChanges();
                result = true;
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clFeesPeriod, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
            return(result);
        }
        public bool SubmitRecord(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.FeesPeriod, "SubmitRecord", "Submit record method called", DayCarePL.Common.GUID_DEFAULT);
            bool result = false;

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.FeesPeriod, "SubmitRecord", "Debug Submit Record Of FeesPeriod", DayCarePL.Common.GUID_DEFAULT);

                DayCareBAL.FeesPeriodService   proxySave     = new DayCareBAL.FeesPeriodService();
                DayCarePL.FeesPeriodProperties objFeesPeriod = new DayCarePL.FeesPeriodProperties();

                Telerik.Web.UI.GridDataItem item = (Telerik.Web.UI.GridDataItem)e.Item;

                var InsertItem = e.Item as Telerik.Web.UI.GridEditableItem;
                Telerik.Web.UI.GridEditManager editMan = InsertItem.EditManager;

                if (InsertItem != null)
                {
                    foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns)
                    {
                        if (column is IGridEditableColumn)
                        {
                            IGridEditableColumn editablecol = (column as IGridEditableColumn);
                            if (editablecol.IsEditable)
                            {
                                IGridColumnEditor editor = editMan.GetColumnEditor(editablecol);
                                switch (column.UniqueName)
                                {
                                case "Name":
                                {
                                    objFeesPeriod.Name = (editor as GridTextBoxColumnEditor).Text.Trim().ToString();
                                    ViewState["Name"]  = objFeesPeriod.Name;
                                    break;
                                }

                                case "Active":
                                {
                                    objFeesPeriod.Active = (editor as GridCheckBoxColumnEditor).Value;
                                    break;
                                }
                                }
                            }
                        }
                    }
                    if (e.CommandName != "PerformInsert")
                    {
                        if (Session["StaffId"] != null)
                        {
                            objFeesPeriod.LastModifiedById = new Guid(Session["StaffId"].ToString());
                        }
                        objFeesPeriod.Id = new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString());
                        if (!objFeesPeriod.Name.Trim().Equals(hdnName.Value.Trim()))
                        {
                            bool ans = Common.CheckDuplicate("FeesPeriod", "Name", objFeesPeriod.Name, "update", objFeesPeriod.Id.ToString());
                            if (ans)
                            {
                                MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                                MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Already Exist", "false"));
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        bool ans = Common.CheckDuplicate("FeesPeriod", "Name", objFeesPeriod.Name, "insert", objFeesPeriod.Id.ToString());
                        if (ans)
                        {
                            MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                            MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Already Exist", "false"));
                            return(false);
                        }
                    }
                    hdnName.Value = "";
                    result        = proxySave.Save(objFeesPeriod);
                    if (result == true)
                    {
                        MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Saved Successfully", "false"));
                    }
                }
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.FeesPeriod, "SubmitRecord", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
            return(result);
        }
 public bool Save(DayCarePL.FeesPeriodProperties objFeesPeriod)
 {
     return(DayCareDAL.clFeesPeriod.Save(objFeesPeriod));
 }