Example #1
0
        public override void Save()
        {
            try
            {
                int orderNo = 1;
                foreach (RadListDataItem item in lstZones.Items)
                {
                    //    objMaster = new ZoneBO();
                    objMaster.GetByPrimaryKey(item.Value);

                    if (objMaster.Current != null)
                    {
                        objMaster.CheckDataValidation = false;
                        objMaster.Current.OrderNo     = orderNo++;

                        objMaster.Save();
                    }
                }


                General.LoadZoneList();
            }
            catch (Exception ex)
            {
                if (objMaster.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objMaster.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
        }
        void Grid_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
        {
            if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove)
            {
                objMaster = new ZoneBO();

                try
                {
                    objMaster.GetByPrimaryKey(grdLister.CurrentRow.Cells["Id"].Value.ToInt());

                    if (objMaster.Current != null)
                    {
                        int    id       = objMaster.Current.Id;
                        string zoneName = objMaster.Current.ZoneName;
                        objMaster.Delete(objMaster.Current);

                        //using (PDADataContext db = new PDADataContext())
                        //{

                        //    Zone objZone = db.Zones.FirstOrDefault(c => c.ZoneName == zoneName && c.ClientId==AppVars.objPolicyConfiguration.DefaultClientId);

                        //    if (objZone != null)
                        //    {
                        //        db.Zones.DeleteOnSubmit(objZone);
                        //        db.SubmitChanges();
                        //    }
                        //}
                    }
                }
                catch (Exception ex)
                {
                    if (objMaster.Errors.Count > 0)
                    {
                        ENUtils.ShowMessage(objMaster.ShowErrors());
                    }
                    else
                    {
                        ENUtils.ShowMessage(ex.Message);
                    }
                    e.Cancel = true;
                }
            }
        }
        private void UpdateZones()
        {
            ZoneBO objMaster = null;

            try
            {
                objMaster = new ZoneBO();
                for (int i = 0; i < grdZones.RowCount; i++)
                {
                    int Id = grdZones.Rows[i].Cells[COL_ZONE.Id].Value.ToInt();

                    objMaster.GetByPrimaryKey(Id);
                    objMaster.Edit();

                    objMaster.Current.BlockPickup   = grdZones.Rows[i].Cells[COL_ZONE.BlockPickup].Value.ToBool();
                    objMaster.Current.BlockDropOff  = grdZones.Rows[i].Cells[COL_ZONE.BlockDropOff].Value.ToBool();
                    objMaster.Current.IsOutsideArea = grdZones.Rows[i].Cells[COL_ZONE.IsLocalArea].Value.ToBool();


                    objMaster.Save();
                    objMaster.Clear();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                if (objMaster.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objMaster.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
        }
Example #4
0
        public override void Save()
        {
            try
            {
                if (objMaster.PrimaryKeyValue == null)
                {
                    objMaster.New();
                }
                else
                {
                    objMaster.Edit();
                }

                objMaster.Current.ZoneName = txtZoneName.Text.Trim();
                objMaster.Current.PostCode = string.Join(",", grdPostCodes.Rows.Select(c => c.Cells[COLS.PostCode].Value.ToStr()).ToArray <string>());


                objMaster.Current.IsBase     = chkBase.Checked;
                objMaster.Current.ShortName  = txtShortName.Text.Trim();
                objMaster.Current.ZoneTypeId = ddlType.SelectedValue.ToIntorNull();

                objMaster.Current.PlotKind = ddlKind.SelectedValue.ToIntorNull();

                string[] skipProperties = new string[] { "Gen_Zones" };


                int orderNo = 1;
                IList <Gen_Zone_AssociatedPostCode> savedList    = objMaster.Current.Gen_Zone_AssociatedPostCodes;
                List <Gen_Zone_AssociatedPostCode>  listofDetail = (from r in grdPostCodes.Rows
                                                                    //where r.Cells[COL_DOCUMENT.FILENAME].Value.ToStr()!=string.Empty
                                                                    select new Gen_Zone_AssociatedPostCode
                {
                    Id = r.Cells[COLS.Id].Value.ToInt(),
                    ZoneId = r.Cells[COLS.MasterId].Value.ToInt(),
                    AreaName = objMaster.Current.ZoneName,
                    PostCode = r.Cells[COLS.PostCode].Value.ToStr().Trim(),
                    OrderNo = orderNo++
                }).ToList();


                Utils.General.SyncChildCollection(ref savedList, ref listofDetail, "Id", skipProperties);


                objMaster.Save();

                General.LoadZoneList();

                //      PDAClass.SaveZone(objMaster.Current);
            }
            catch (Exception ex)
            {
                if (objMaster.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objMaster.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
        }