Exemplo n.º 1
0
        protected void lnkSave_Click(object sender, EventArgs e)
        {
            var locations = new Locations();

            _locations = LocationDetails;
            foreach (GridViewRow gvRow in GridViewTable.Rows)
            {
                locations.Add(new Location
                {
                    Type        = Type,
                    Catg1       = Region,
                    Catg2       = ddlRegion.SelectedItem.Text,
                    Id          = ((TextBox)gvRow.FindControl("txtId")).Text.Trim().ToUpper(),
                    Description = ((TextBox)gvRow.FindControl("txtDescription")).Text,
                    Parent      = Constants.LabelWarehouse,
                    Created     = Dates.ToDateTime(((HiddenField)gvRow.FindControl("hidCreatedDate")).Value.Trim(), DateFormat.Format_01),
                    Suspend     = ((HiddenField)gvRow.FindControl("hidSuspent")).Value.Trim().ToBool(),
                    Action      = (string.IsNullOrEmpty((((HiddenField)gvRow.FindControl("hdnAction")).Value)) ? Constants.UpdateAction : ((HiddenField)gvRow.FindControl("hdnAction")).Value),
                });
            }
            var firstOrDefault = locations.FirstOrDefault();

            if (firstOrDefault != null)
            {
                firstOrDefault.DataBaseInfo = UserContext.DataBaseInfo;
            }


            if (_controlPanel.SetLocation(locations))
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.LocationSaved;
                CustomMessageControl.MessageType     = MessageTypes.Success;
                CustomMessageControl.ShowMessage();
                AuditLog.LogEvent(UserContext, SysEventType.INFO, "LOCATION SAVED",
                                  GlobalCustomResource.LocationSaved, true);
                lnkAddNew.Enabled = true;
                lnkAddNew.Style.Add("cursor", "Pointer");
                BindData();
            }
            else
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.LocationFailed;
                CustomMessageControl.MessageType     = MessageTypes.Error;
                CustomMessageControl.ShowMessage();
                AuditLog.LogEvent(UserContext, SysEventType.INFO, "LOCATION UPDATE FAILED",
                                  GlobalCustomResource.LocationFailed, true);
            }
        }