Exemplo n.º 1
0
        public void bntCreate_Click(Object sender, EventArgs e)
        {
            var id = Page.Request.Params["id"];
            var marginCoefficient = tbMarginCoefficient.Text.Replace(".", ",") == String.Empty ? 0 : Convert.ToDouble(tbMarginCoefficient.Text.Replace(".", ","));
            var weightmin         = tbWeightMin.Text.Replace(".", ",") == String.Empty ? 0 : Convert.ToDouble(tbWeightMin.Text.Replace(".", ","));
            var weightmax         = tbWeightMax.Text.Replace(".", ",") == String.Empty ? 0 : Convert.ToDouble(tbWeightMax.Text.Replace(".", ","));
            var title             = new Titles
            {
                Name = tbName.Text.Replace("\"", "''"),
                MarginCoefficient         = marginCoefficient,
                WeightMin                 = weightmin,
                WeightMax                 = weightmax,
                Additive                  = cbAdditive.Checked ? 1 : 0,
                CanBeWithoutAkciza        = cbCanBeWithoutAkciza.Checked ? 1 : 0,
                CategoryID                = Convert.ToInt32(ddlCategory.SelectedValue),
                AdditiveCostWithoutAkciza = Convert.ToDouble(tbAdditiveCostWithoutAkciza.Text),
            };

            if (id == null)
            {
                title.Create();
            }
            else
            {
                title.ID = Convert.ToInt32(id);
                title.Update();
            }
            Page.Response.Redirect("~/ManagerUI/Menu/Souls/TitlesView.aspx");
        }