Exemplo n.º 1
0
        public static bool Save(DayCarePL.RelationshipProperties objRelationship)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clRelationship, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT);
            clConnection.DoConnection();

            DayCareDataContext db             = new DayCareDataContext();
            Relationship       DBRelationship = null;

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clRelationship, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT);

                if (objRelationship.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
                {
                    DBRelationship    = new Relationship();
                    DBRelationship.Id = System.Guid.NewGuid();
                }
                else
                {
                    DBRelationship = db.Relationships.SingleOrDefault(u => u.Id.Equals(objRelationship.Id));
                }
                DBRelationship.Name                 = objRelationship.Name;
                DBRelationship.SchoolId             = objRelationship.SchoolId;
                DBRelationship.Active               = objRelationship.Active;
                DBRelationship.Comments             = objRelationship.Comments;
                DBRelationship.LastModifiedById     = objRelationship.LastModifiedById;
                DBRelationship.LastModifiedDatetime = DateTime.Now;

                if (objRelationship.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
                {
                    db.Relationships.InsertOnSubmit(DBRelationship);
                }
                db.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clRelationship, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                return(false);
            }
        }
Exemplo n.º 2
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;

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.SchoolYear, "SubmitRecord", "Debug Submit Record Of SchoolYear", DayCarePL.Common.GUID_DEFAULT);
                DayCareBAL.RelationshipService   proxyRelationship = new DayCareBAL.RelationshipService();
                DayCarePL.RelationshipProperties objRelationship   = new DayCarePL.RelationshipProperties();

                GridDataItem item       = (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 GridEditableColumn)
                        {
                            IGridEditableColumn editTableColumn = (column as IGridEditableColumn);

                            if (editTableColumn.IsEditable)
                            {
                                IGridColumnEditor editor = editMan.GetColumnEditor(editTableColumn);

                                switch (column.UniqueName)
                                {
                                case "Name":
                                {
                                    objRelationship.Name = (e.Item.FindControl("txtName") as TextBox).Text;
                                    break;
                                }

                                case "Comments":
                                {
                                    objRelationship.Comments = (e.Item.FindControl("txtComments") as TextBox).Text;
                                    break;
                                }

                                case "Active":
                                {
                                    objRelationship.Active = (editor as GridCheckBoxColumnEditor).Value;
                                    break;
                                }
                                }
                            }
                        }
                    }

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

                    if (e.CommandName != "PerformInsert")
                    {
                        objRelationship.Id = new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString());

                        bool ans = proxyRelationship.CheckDuplicateRelationshipName(objRelationship.Name, objRelationship.Id, objRelationship.SchoolId);
                        if (ans)
                        {
                            MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                            MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Relationship name Already Exist", "false"));
                            return(false);
                        }

                        if (Session["StaffId"] != null)
                        {
                            objRelationship.LastModifiedById = new Guid(Session["StaffId"].ToString());
                        }
                    }
                    else
                    {
                        bool ans = proxyRelationship.CheckDuplicateRelationshipName(objRelationship.Name, objRelationship.Id, objRelationship.SchoolId);
                        if (ans)
                        {
                            MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                            MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Relationship name Already Exist", "false"));
                            return(false);
                        }
                    }
                    hdnName.Value = "";

                    result = proxyRelationship.Save(objRelationship);
                    if (result)
                    {
                        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.Relationship, "SubmitRecord", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
            return(result);
        }
Exemplo n.º 3
0
 public bool Save(DayCarePL.RelationshipProperties objRelationship)
 {
     return(DayCareDAL.clRelationship.Save(objRelationship));
 }