Ejemplo n.º 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            if (string.IsNullOrEmpty(this.hdnStuffId.Value))
            {
                SupplySystem.REP_Stuff stuff = new SupplySystem.REP_Stuff
                {
                    StuffName = this.txtGoodName.Text.Trim(),
                    StuffTypeID = Public.ToByte(this.drpStuffTypes.SelectedValue),
                    TechnicalInfo = this.txtTechnicalInfo.Text,
                    PrimaryUnitID = Public.ToByte(this.drpFirstUnit.SelectedValue),
                    SecondaryUnitID = Public.ToByte(this.drpSecondUnit.SelectedValue),
                    ThirdUnitID = Public.ToByte(this.drpThirdUnit.SelectedValue),
                    FirstConversionCoefficient = Public.ToByte(this.txtFirstConversionCoefficient.Text),
                    SecondConversionCoefficient = Public.ToByte(this.txtSecondConversionCoefficient.Text),
                    ProducerCompany = this.txtProducerCompany.Text,
                    ProducerCountry = this.txtProducerCountry.Text,
                    Capacity = this.txtCapacity.Text,
                    Color = this.txtColor.Text,
                    Size = this.txtSize.Text,
                    SubmitDate = DateTime.Now.Date
                };

                db.REP_Stuffs.InsertOnSubmit(stuff);
            }
            else
            {
                SupplySystem.REP_Stuff stuff = db.REP_Stuffs.SingleOrDefault(st => st.StuffID == Public.ToInt(this.hdnStuffId.Value));
                if (stuff != null)
                {
                    stuff.StuffName = this.txtGoodName.Text.Trim();
                    stuff.StuffTypeID = Public.ToByte(this.drpStuffTypes.SelectedValue);
                    stuff.TechnicalInfo = this.txtTechnicalInfo.Text;
                    stuff.PrimaryUnitID = Public.ToByte(this.drpFirstUnit.SelectedValue);
                    stuff.SecondaryUnitID = Public.ToByte(this.drpSecondUnit.SelectedValue);
                    stuff.ThirdUnitID = Public.ToByte(this.drpThirdUnit.SelectedValue);
                    stuff.FirstConversionCoefficient = Public.ToByte(this.txtFirstConversionCoefficient.Text);
                    stuff.SecondConversionCoefficient = Public.ToByte(this.txtSecondConversionCoefficient.Text);
                    stuff.ProducerCompany = this.txtProducerCompany.Text;
                    stuff.ProducerCountry = this.txtProducerCountry.Text;
                    stuff.Capacity = this.txtCapacity.Text;
                    stuff.Color = this.txtColor.Text;
                    stuff.Size = this.txtSize.Text;
                }
            }

            db.SubmitChanges();
            this.grdStuffs.DataSource = db.REP_Stuffs.Where(st => st.StuffTypeID == Public.ToByte(this.drpStuffTypes.SelectedValue)).Select(st => new { st.StuffID, st.StuffName }).ToList();
            this.grdStuffs.DataBind();
            this.lblMessage.Text = Public.SUCCESSMESSAGE;
            SetControls(null);
        }
    }
Ejemplo n.º 2
0
 partial void DeleteREP_Stuff(REP_Stuff instance);
Ejemplo n.º 3
0
 partial void UpdateREP_Stuff(REP_Stuff instance);
Ejemplo n.º 4
0
 partial void InsertREP_Stuff(REP_Stuff instance);
Ejemplo n.º 5
0
		private void detach_REP_Stuffs_REP_Units2s(REP_Stuff entity)
		{
			this.SendPropertyChanging();
			entity.ThirdUnit = null;
		}
Ejemplo n.º 6
0
		private void detach_Units(REP_Stuff entity)
		{
			this.SendPropertyChanging();
			entity.SecondaryUnit = null;
		}
Ejemplo n.º 7
0
		private void attach_REP_Stuffs(REP_Stuff entity)
		{
			this.SendPropertyChanging();
			entity.REP_Unit = this;
		}
Ejemplo n.º 8
0
		private void detach_REP_Stuffs(REP_Stuff entity)
		{
			this.SendPropertyChanging();
			entity.REP_StuffType = null;
		}