Beispiel #1
0
    void BindFuelConsume()
    {
        OtherFuelConsumeService consumseService = new OtherFuelConsumeService();
        int FuelId = 0;

        if (ddlFuel.SelectedIndex > 0)
        {
            FuelId = Convert.ToInt32(ddlFuel.SelectedValue);
        }
        DataTable dt = consumseService.GetDataByFuel(ReportId, FuelId);

        if (dt != null && dt.Rows.Count <= 0)
        {
            for (int i = 1; i <= 12; i++)
            {
                DataRow dr = dt.NewRow();
                //dr["Quantity"] = 0;
                //dr["Cost"] = 0;
                dt.Rows.Add(dr);
            }
        }
        else
        {
            try
            {
                ddlMeasure.SelectedValue = dt.Rows[0]["MeasurementId"].ToString();
            }
            catch { }
        }
        rptDataFuel.DataSource = dt;
        rptDataFuel.DataBind();
    }
Beispiel #2
0
    void BindData()
    {
        OtherFuelConsumeService consumseService = new OtherFuelConsumeService();
        DataSet ds = consumseService.GetAuditFuel(ReportId);

        if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
        {
            StringBuilder sb     = new StringBuilder();
            StringBuilder sbSub  = new StringBuilder();
            StringBuilder sbData = new StringBuilder();
            sb.Append("<table class='table table-bordered table-hover mbn' width='100%'>");
            sb.Append("<thead>");
            sb.Append("<tr>");
            sb.Append("<th rowspan='2' class='text-center'>Tháng</th>");
            sbSub.Append("<tr>");
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                sb.Append("<th colspan='2' class='text-center'>" + ds.Tables[0].Rows[i]["FuelName"] + "</th>");
                sbSub.Append("<th class='text-center'>Khối lượng" + "<br/><i>(" + ds.Tables[0].Rows[i]["MeasurementName"] + ")</i>" + "</th>");
                sbSub.Append("<th class='text-center'>Chi phí <br/><i>(nghìn đồng)</i></th>");
            }
            sbSub.Append("</tr>");
            sb.Append("</tr>");
            sb.Append(sbSub.ToString());
            sb.Append("</thead>");
            for (int j = 1; j <= 12; j++)
            {
                sbData.Append("<tr>");
                sbData.Append("<td class='text-center'>" + j + "</td>");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow[] dr = ds.Tables[1].Select("FuelId=" + ds.Tables[0].Rows[i]["Id"].ToString() + " AND MonthUsed=" + j);
                    if (dr.Count() > 0)
                    {
                        for (int t = 0; t < dr.Count(); t++)
                        {
                            sbData.Append("<td class='text-right'>" + Tool.ConvertDecimalToString(dr[t]["Quantity"], 2) + "</td>");
                            sbData.Append("<td class='text-right'>" + Tool.ConvertDecimalToString(dr[t]["Cost"], 0) + "</td>");
                        }
                    }
                    else
                    {
                        sbData.Append("<td class='text-right'>-</td>");
                        sbData.Append("<td class='text-right'>-</td>");
                    }
                }
                sbData.Append("</tr>");
            }
            sb.Append(sbData.ToString());
            sb.Append("</table>");
            ltOtherEneryConsume.Text = sb.ToString();
        }
    }
Beispiel #3
0
    protected void btnDeleteFuelConsume_Click(object sender, EventArgs e)
    {
        int FuelId = Convert.ToInt32(ddlFuel.SelectedValue);
        OtherFuelConsumeService otherService = new OtherFuelConsumeService();

        if (otherService.DeleteByFuel(ReportId, FuelId) >= 0)
        {
            ltErrConsume.Text = "Xóa thành công";
            BindFuelConsume();
            BindData();
            ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogFuelConsume();", true);
        }
    }
Beispiel #4
0
    protected void btnSaveFuel_Click(object sender, EventArgs e)
    {
        int FuelId    = Convert.ToInt32(ddlFuel.SelectedValue);
        int MeasureId = Convert.ToInt32(ddlMeasure.SelectedValue);
        OtherFuelConsumeService otherService = new OtherFuelConsumeService();

        if (otherService.DeleteByFuel(ReportId, FuelId) >= 0)
        {
            for (int i = 1; i <= 12; i++)
            {
                string           strQuantity = Request.Form["txtQuantity" + i];
                string           strCost     = Request.Form["txtCost" + i];
                OtherFuelConsume other       = new OtherFuelConsume();
                try
                {
                    if (strQuantity != null && strQuantity.Trim() != "")
                    {
                        other.Quantity = Convert.ToDecimal(strQuantity.Trim());
                    }
                    if (strCost != null && strCost.Trim() != "")
                    {
                        other.Cost = Convert.ToDecimal(strCost.Trim());
                    }
                }
                catch (Exception ex)
                {
                }
                other.FuelId        = FuelId;
                other.AuditReportId = ReportId;
                other.MonthUsed     = i;
                other.MeasurementId = MeasureId;
                otherService.Insert(other);
            }
            BindData();
            BindFuelConsume();
            ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogFuelConsume();", true);
        }
    }