示例#1
0
        public static bool Save(DayCarePL.StateProperties objState)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clState, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT);
            clConnection.DoConnection();
            bool result           = false;
            DayCareDataContext db = new DayCareDataContext();
            State DBState         = null;

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clState, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT);
                Configuration myConfiguration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
                XDocument     xDoc            = XDocument.Load(myConfiguration.FilePath.ToLower().Remove(myConfiguration.FilePath.ToLower().IndexOf("web.config")) + "XML\\StateList.xml");

                if (objState.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
                {
                    DBState    = new State();
                    DBState.Id = Guid.NewGuid();
                    xDoc.Element("States").Add(new XElement("State", new XElement("Id", DBState.Id), new XElement("Name", objState.Name), new XElement("CountryId", objState.CountryId)));
                    xDoc.Save(myConfiguration.FilePath.ToLower().Remove(myConfiguration.FilePath.ToLower().IndexOf("web.config")) + "XML\\StateList.xml");
                }
                else
                {
                    DBState = db.States.SingleOrDefault(c => c.Id.Equals(objState.Id));
                    var statedata = (from c in xDoc.Descendants("State")
                                     where c.Element("Id").Value.Equals(objState.Id.ToString())
                                     select c).Single();

                    statedata.Element("Name").Value      = objState.Name;
                    statedata.Element("CountryId").Value = Convert.ToString(objState.CountryId);
                    xDoc.Save(myConfiguration.FilePath.ToLower().Remove(myConfiguration.FilePath.ToLower().IndexOf("web.config")) + "XML\\StateList.xml");
                }
                DBState.Name      = objState.Name;
                DBState.CountryId = objState.CountryId;
                if (objState.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
                {
                    db.States.InsertOnSubmit(DBState);
                }
                db.SubmitChanges();
                result = true;
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clState, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
            return(result);
        }
示例#2
0
 protected void rgStates_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
 {
     if (e.Item.ItemType == GridItemType.EditItem)
     {
         DayCarePL.StateProperties objState = e.Item.DataItem as DayCarePL.StateProperties;
         DropDownList ddlCountry            = e.Item.FindControl("ddlCountry") as DropDownList; //(DropDownList)gridEditFormItem["Name"].FindControl("ddlCountry");
         Common.BindCountryDropDown(ddlCountry);
         if (ddlCountry.Items != null && ddlCountry.Items.Count > 0)
         {
             if (objState != null)
             {
                 ddlCountry.SelectedValue = objState.CountryId.ToString();
             }
         }
     }
 }
示例#3
0
 public bool Save(DayCarePL.StateProperties objState)
 {
     return(DayCareDAL.clState.Save(objState));
 }
示例#4
0
        public bool SubmitRecord(object source, GridCommandEventArgs e)
        {
            bool result = false;

            try
            {
                DayCareBAL.StateService   proxyState = new DayCareBAL.StateService();
                DayCarePL.StateProperties objState   = new DayCarePL.StateProperties();

                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":
                                {
                                    objState.Name = (item["Name"].Controls[1] as TextBox).Text;
                                    break;
                                }

                                case "CountryName":
                                {
                                    objState.CountryId = new Guid((e.Item.FindControl("ddlCountry") as DropDownList).SelectedValue);
                                    break;
                                }
                                }
                            }
                        }
                    }
                    if (e.CommandName != "PerformInsert")
                    {
                        objState.Id = new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString());
                        if (!objState.Name.Trim().Equals(hdnName.Value.Trim()))
                        {
                            bool ans = Common.CheckDuplicate("State", "Name", objState.Name, "update", objState.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("State", "Name", objState.Name, "insert", "");
                        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 = proxyState.Save(objState);
                    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.State, "SubmitRecord", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
            return(result);
        }