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 #2
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);
                }
            }
        }