コード例 #1
0
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                // First lets save the product
                UnitInfo unit  = null;
                bool     isNew = false;

                if (UnitId >= 0)
                {
                    unit = Controller.GetUnit(UnitId);
                }
                else
                {
                    isNew = true;
                }

                if (unit != null)
                {
                    unit.Decimals = Convert.ToInt32(txtDecimals.Text);
                    Controller.UpdateUnit(unit);
                }
                else
                {
                    unit          = new UnitInfo();
                    unit.PortalId = PortalId;
                    unit.Decimals = Convert.ToInt32(txtDecimals.Text);
                    UnitId        = Controller.NewUnit(unit);
                }

                // Now lets update Language information
                lngUnits.UpdateLangs();
                Controller.DeleteUnitLangs(UnitId);
                foreach (UnitLangInfo ul in lngUnits.Langs)
                {
                    ul.UnitId = UnitId;
                    Controller.NewUnitLang(ul);
                }

                List <string> addParams = new List <string>();

                if (Request["adminmode"] != null)
                {
                    addParams.Add("adminmode=unitlist");
                }
                addParams.Add("unitId=" + UnitId.ToString());

                Response.Redirect(Globals.NavigateURL(TabId, "", addParams.ToArray()), true);
            }
            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }