示例#1
0
 protected void rgFont_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
 {
     if (e.Item.ItemType == GridItemType.EditItem)
     {
         RadColorPicker picker = (RadColorPicker)e.Item.FindControl("rcpColor");
         if (picker != null)
         {
             DayCarePL.FontProperties objFont = e.Item.DataItem as DayCarePL.FontProperties;
             if (objFont != null)
             {
                 picker.SelectedColor = ColorTranslator.FromHtml((DataBinder.Eval(objFont, "Color").ToString()));
             }
         }
     }
     if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
     {
         DayCarePL.FontProperties item = e.Item.DataItem as DayCarePL.FontProperties;
         Label lblColor = e.Item.FindControl("lblColor") as Label;
         lblColor.Height    = 25;
         lblColor.Width     = 25;
         lblColor.BackColor = System.Drawing.ColorTranslator.FromHtml(item.Color);
     }
     if (e.Item.ItemIndex == -1)
     {
         if (e.Item.Edit == true)
         {
             GridEditableItem dataItem  = e.Item as Telerik.Web.UI.GridEditableItem;
             CheckBox         chkActive = dataItem["Active"].Controls[0] as CheckBox;
             chkActive.Checked = true;
         }
     }
 }
示例#2
0
        public static bool Save(DayCarePL.FontProperties objFont)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clFont, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT);
            clConnection.DoConnection();
            bool result           = false;
            DayCareDataContext db = new DayCareDataContext();
            Font DBFont           = null;

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clFont, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT);
                if (objFont.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
                {
                    DBFont    = new Font();
                    DBFont.Id = System.Guid.NewGuid();
                }
                else
                {
                    DBFont = db.Fonts.SingleOrDefault(F => F.Id.Equals(objFont.Id));
                }
                DBFont.Name   = objFont.Name;
                DBFont.Color  = objFont.Color;
                DBFont.Size   = objFont.Size;
                DBFont.Active = objFont.Active;
                if (objFont.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
                {
                    db.Fonts.InsertOnSubmit(DBFont);
                }
                db.SubmitChanges();
                result = true;
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clFont, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
            return(result);
        }
示例#3
0
 public bool Save(DayCarePL.FontProperties objFont)
 {
     return(DayCareDAL.clFont.Save(objFont));
 }
示例#4
0
        public bool SubmitRecord(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.Font, "SubmitRecord", "Submit record method called", DayCarePL.Common.GUID_DEFAULT);
            bool   result   = false;
            string FontSize = "";

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.Font, "SubmitRecord", " Debug Submit record method called of Font", DayCarePL.Common.GUID_DEFAULT);

                DayCareBAL.FontService   proxySave = new DayCareBAL.FontService();
                DayCarePL.FontProperties objFont   = new DayCarePL.FontProperties();

                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":
                                {
                                    objFont.Name      = (editor as GridTextBoxColumnEditor).Text.Trim().ToString();
                                    ViewState["Name"] = objFont.Name;
                                    break;
                                }

                                case "Color":
                                {
                                    //objFont.Color=(e.Item.FindControl("rcpColor") as RadColorPicker ).
                                    if ((e.Item.FindControl("rcpColor") as RadColorPicker) != null && (e.Item.FindControl("rcpColor") as RadColorPicker).SelectedColor.Name != "0")
                                    {
                                        objFont.Color = "#" + (e.Item.FindControl("rcpColor") as RadColorPicker).SelectedColor.Name;
                                    }

                                    break;
                                }

                                case "Size":
                                {
                                    FontSize = (e.Item.FindControl("txtSize") as TextBox).Text.Trim();
                                    //objFont.Size = Convert.ToInt32((e.Item.FindControl("txtSize") as TextBox).Text.Trim());
                                    ViewState["Size"] = objFont.Size;
                                    break;
                                }

                                case "Active":
                                {
                                    objFont.Active = (editor as GridCheckBoxColumnEditor).Value;
                                    break;
                                }
                                }
                            }
                        }
                    }
                    int res = 0;
                    Int32.TryParse(FontSize, out res);
                    if (res == 0)
                    {
                        MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Font size must be numeric.", "false"));
                        return(false);
                    }
                    else
                    {
                        objFont.Size = Convert.ToInt32(FontSize);
                    }
                    if (string.IsNullOrEmpty(objFont.Color))
                    {
                        MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Please select color.", "false"));
                        return(false);
                    }
                    if (e.CommandName != "PerformInsert")
                    {
                        //objFont.Id = new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString());
                        objFont.Id = new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString());
                        if (!objFont.Name.Trim().Equals(hdnName.Value.Trim()))
                        {
                            bool ans = Common.CheckDuplicate("Font", "Name", objFont.Name, "update", objFont.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("Font", "Name", objFont.Name, "insert", objFont.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(objFont);
                    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.Font, "SubmitRecord", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
            return(result);
        }