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

            lnkAddNew.Enabled = true;
            lnkAddNew.Style.Add("cursor", "Pointer");
            foreach (GridViewRow gvRow in GridViewTable.Rows)
            {
                units.Add(new FBTS.Model.Control.Unit
                {
                    Id          = ((TextBox)gvRow.FindControl("txtPrimary")).Text.Trim().ToUpper(),
                    Description = ((TextBox)gvRow.FindControl("txtSecondary")).Text.Trim().ToUpper(),
                    Suspend     = ((HiddenField)gvRow.FindControl("hidSuspend")).Value.Trim().ToBool(),
                    Action      = (string.IsNullOrEmpty((((HiddenField)gvRow.FindControl("hdnAction")).Value)) ? Constants.UpdateAction : ((HiddenField)gvRow.FindControl("hdnAction")).Value),
                });
            }
            var firstOrDefault = units.FirstOrDefault();

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

            if (_controlPanel.SetUom(units))
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.UOMSaved;
                CustomMessageControl.MessageType     = MessageTypes.Success;
                CustomMessageControl.ShowMessage();
                AuditLog.LogEvent(UserContext, SysEventType.INFO, "UOM SAVED",
                                  GlobalCustomResource.UOMSaved, true);
                lnkAddNew.Enabled = true;
                lnkAddNew.Style.Add("cursor", "Pointer");
                BindData();
            }
            else
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.UOMFailed;
                CustomMessageControl.MessageType     = MessageTypes.Error;
                CustomMessageControl.ShowMessage();
                AuditLog.LogEvent(UserContext, SysEventType.INFO, "UOM UPDATE FAILED",
                                  GlobalCustomResource.UOMFailed, true);
            }
        }