コード例 #1
0
        public MeasurementFuel Update(MeasurementFuel obj)
        {
            MeasurementFuelBO measurementfuelBO = new MeasurementFuelBO(obj);

            measurementfuelDao.Update(measurementfuelBO);
            return(obj);
        }
コード例 #2
0
ファイル: ListFuel.ascx.cs プロジェクト: vietnnit/dataenergy
    protected void btnSave_Click(object sender, EventArgs e)
    {
        FuelService fuelService = new FuelService();
        Fuel        fuel        = new Fuel();
        int         FuelId      = 0;

        if (hdnEditId.Value != "")
        {
            try
            {
                FuelId = Convert.ToInt32(hdnEditId.Value.Trim());
            }
            catch
            { }
        }
        fuel.FuelName = txtTitle.Text.Trim();
        if (ddlGroupFuel.SelectedIndex > 0)
        {
            fuel.GroupFuelId = Convert.ToInt32(ddlGroupFuel.SelectedValue);
        }
        if (ddlMeasurement.SelectedIndex > 0)
        {
            fuel.MeasurementId = Convert.ToInt32(ddlMeasurement.SelectedValue);
        }
        if (FuelId > 0)
        {
            fuel.Id = FuelId;
            if (fuelService.Update(fuel) != null)
            {
                BindData();
                hdnEditId.Value = "0";
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showform", "updateFuel();", true);
            }
        }
        else
        {
            int id = fuelService.Insert(fuel);
            if (id > 0)
            {
                MeasurementFuelService measurementFuelService = new MeasurementFuelService();
                MeasurementFuel        objMeasurementFuel     = new MeasurementFuel();
                if (txtNoCO2_S.Text != "")
                {
                    objMeasurementFuel.NoCO2 = Convert.ToDecimal(txtNoCO2_S.Text.Trim());
                }
                if (txtFromTOE_S.Text != "" && txtToTOE_S.Text.Trim() != "" && ddlMeasurement.SelectedValue != "" && id > 0)
                {
                    if (ddlMeasurement.SelectedValue != "")
                    {
                        objMeasurementFuel.MeasurementId = Convert.ToInt32(ddlMeasurement.SelectedValue);
                    }
                    objMeasurementFuel.FuelId = fuel.Id;
                    decimal dfrom = 0;
                    decimal dto   = 0;
                    try
                    {
                        dfrom = Convert.ToDecimal(txtFromTOE_S.Text);
                    }
                    catch
                    {
                    }
                    if (txtToTOE_S.Text != "" && txtToTOE_S.Text.Trim() != "")
                    {
                        try
                        {
                            dto = Convert.ToDecimal(txtToTOE_S.Text.Trim());
                        }
                        catch
                        {
                        }
                    }
                    if (dfrom > 0)
                    {
                        objMeasurementFuel.From_TOE = dfrom;
                        objMeasurementFuel.TOE      = dfrom;
                    }
                    if (dto >= 0 && dto > dfrom)
                    {
                        objMeasurementFuel.To_TOE = dto;
                    }
                }
                measurementFuelService.UpdateTOE(objMeasurementFuel.FuelId, objMeasurementFuel.MeasurementId, objMeasurementFuel.From_TOE, objMeasurementFuel.To_TOE);
                BindData();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showform", "addFuel();", true);
            }
        }
    }
コード例 #3
0
        public int Insert(MeasurementFuel obj)
        {
            MeasurementFuelBO measurementfuelBO = new MeasurementFuelBO(obj);

            return(measurementfuelDao.Insert(measurementfuelBO));
        }
コード例 #4
0
ファイル: ListFuel.ascx.cs プロジェクト: vietnnit/dataenergy
    protected void btnSaveTOE_Click(object sender, EventArgs e)
    {
        MeasurementFuelService measurementFuelService = new MeasurementFuelService();
        MeasurementFuel        objMeasurementFuel     = new MeasurementFuel();
        int mId = 0;
        int fid = 0;

        if (hdnToeId.Value != "")
        {
            try
            {
                mId = Convert.ToInt32(hdnToeId.Value.Trim());
            }
            catch
            { }
        }
        if (hdnfuelid.Value != "")
        {
            try
            {
                fid = Convert.ToInt32(hdnfuelid.Value.Trim());
            }
            catch
            { }
        }
        if (txtNoCO2.Text != "")
        {
            objMeasurementFuel.NoCO2 = Convert.ToDecimal(txtNoCO2.Text.Trim());
        }
        if (txttoeFrom.Text != "" && txttoeFrom.Text.Trim() != "" && ddlMeasurement1.SelectedValue != "" && fid > 0)
        {
            if (ddlMeasurement1.SelectedValue != "")
            {
                objMeasurementFuel.MeasurementId = Convert.ToInt32(ddlMeasurement1.SelectedValue);
            }
            objMeasurementFuel.FuelId = fid;
            decimal dfrom = 0;
            decimal dto   = 0;
            try
            {
                dfrom = Convert.ToDecimal(txttoeFrom.Text);
            }
            catch
            {
            }
            if (txttoeto.Text != "" && txttoeto.Text.Trim() != "")
            {
                try
                {
                    dto = Convert.ToDecimal(txttoeto.Text.Trim());
                }
                catch
                {
                }
            }
            if (dfrom > 0)
            {
                objMeasurementFuel.From_TOE = dfrom;
                objMeasurementFuel.TOE      = dfrom;
            }
            if (dto >= 0 && dto > dfrom)
            {
                objMeasurementFuel.To_TOE = dto;
            }

            if (mId > 0)
            {
                objMeasurementFuel.Id = mId;
                if (measurementFuelService.Update(objMeasurementFuel) != null)
                {
                    BindData();
                    hdnToeId.Value  = "0";
                    hdnfuelid.Value = "0";
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showform", "showupdatetoefuel();", true);
                }
            }
            else
            {
                if (measurementFuelService.Insert(objMeasurementFuel) > 0)
                {
                    BindData();
                    hdnToeId.Value  = "0";
                    hdnfuelid.Value = "0";
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showform", "addtoefuel();", true);
                }
            }
        }
    }