1
Reply

dataset

garbage

garbage

Jun 28 2006 7:29 AM
1.9k

i have these very long lines of code. which i think can be shorten.

it has a master data that which came from dataset "ds".
from the set of data in ds. it willl get another data that which give the master data its details.

how can i make this lines of code shorter.?.
[CODE]

dsDetails = altStock.fetchStockDetails(ds.Tables[0].Rows[rowIndex]["customerCode"].ToString());
            decimal wareQty = dsDetails.Tables[0].Rows[0]["custQty"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custQty"]);
            decimal prodQty = dsDetails.Tables[0].Rows[0]["custName"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custName"]);
            decimal finQty = wareQty + prodQty;
            this.txtDesc.Text = dsDetails.Tables[0].Rows[0]["custAddress"].ToString();
            this.txtQty.Text = finQty.ToString();
            this.txtSpecs.Text = dsDetails.Tables[0].Rows[0]["custAddress1"].ToString();


            dsDetails = altStock.fetchStockDetails(ds.Tables[0].Rows[rowIndex]["customerCode1"].ToString());
            wareQty = dsDetails.Tables[0].Rows[0]["custQty"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custQty"]);
            prodQty = dsDetails.Tables[0].Rows[0]["custName"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custName"]);
            finQty = wareQty + prodQty;
            this.txtDesc1.Text = dsDetails.Tables[0].Rows[0]["custAddress"].ToString();
            this.txtQty1.Text = finQty.ToString();
            this.txtSpecs1.Text = dsDetails.Tables[0].Rows[0]["custAddress1"].ToString();

            dsDetails = altStock.fetchStockDetails(ds.Tables[0].Rows[rowIndex]["customerCode2"].ToString());
            wareQty = dsDetails.Tables[0].Rows[0]["custQty"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custQty"]);
            prodQty = dsDetails.Tables[0].Rows[0]["custName"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custName"]);
            finQty = wareQty + prodQty;
            this.txtDesc2.Text = dsDetails.Tables[0].Rows[0]["custAddress"].ToString();
            this.txtQty2.Text = finQty.ToString();
            this.txtSpecs2.Text = dsDetails.Tables[0].Rows[0]["custAddress1"].ToString();

            dsDetails = altStock.fetchStockDetails(ds.Tables[0].Rows[rowIndex]["Amt_AltStockcode3"].ToString());
            wareQty = dsDetails.Tables[0].Rows[0]["custQty"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custQty"]);
            prodQty = dsDetails.Tables[0].Rows[0]["custName"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custName"]);
            finQty = wareQty + prodQty;
            this.txtDesc4.Text = dsDetails.Tables[0].Rows[0]["custAddress"].ToString();
            this.txtQty3.Text = finQty.ToString();
            this.txtSpecs3.Text = dsDetails.Tables[0].Rows[0]["custAddress1"].ToString();

            dsDetails = altStock.fetchStockDetails(ds.Tables[0].Rows[rowIndex]["customerCode4"].ToString());
            wareQty = dsDetails.Tables[0].Rows[0]["custQty"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custQty"]);
            prodQty = dsDetails.Tables[0].Rows[0]["custName"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custName"]);
            finQty = wareQty + prodQty;
            this.txtStockDesc.Text = dsDetails.Tables[0].Rows[0]["custAddress"].ToString();
            this.txtQty4.Text = finQty.ToString();
            this.txtSpecs4.Text = dsDetails.Tables[0].Rows[0]["custAddress1"].ToString();

            dsDetails = altStock.fetchStockDetails(ds.Tables[0].Rows[rowIndex]["customerCode5"].ToString());
            wareQty = dsDetails.Tables[0].Rows[0]["custQty"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custQty"]);
            prodQty = dsDetails.Tables[0].Rows[0]["custName"] == null ? 0 : Convert.ToDecimal(dsDetails.Tables[0].Rows[0]["custName"]);
            finQty = wareQty + prodQty;
            this.txtDesc5.Text = dsDetails.Tables[0].Rows[0]["custAddress"].ToString();
            this.txtQty5.Text = finQty.ToString();
            this.txtSpecs5.Text = dsDetails.Tables[0].Rows[0]["custAddress1"].ToString();[/CODE]


Answers (1)