コード例 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //Response.Write(Session["UserID"].ToString());
     String oid = Request.QueryString["oid"] == null ? "" : Request.QueryString["oid"].ToString();
     //string uid = "6";
     //Session["StoreID"] = storeid;//the session set caused problem!
     //Session["UserID"] = uid;
     if (oid != "")
     {
         randb objrandb = new randb();
         randbXmpie objXmpie = new randbXmpie();
         DataSet exopid = objXmpie.CierantRandBGetOrderProductIDsfromOrder(Convert.ToInt32(oid));
         DataTable tblopid = exopid.Tables[0];
         int userid = uStore.Common.BLL.CustomerInfo.Current.UserID;
         decimal total = 0;
         string availablebudget = "";
         string store_id = Session["StoreID"].ToString();
         if (tblopid.Rows.Count > 0)
         {
             for (int o = 0; o < tblopid.Rows.Count; o++)
             {
                 decimal dstartingbudget = 0;
                 decimal dremaining = 0;
                 decimal davailbudget = 0;
                 string staringdatetime = "";
                 string startingbudget = "";
                 DataRow opRow = tblopid.Rows[o];
                 string opid = opRow["OrderProductID"] == null ? "" : opRow["OrderProductID"].ToString();
                 string EncryptedOrderId = opRow["EncryptedOrderId"] == null ? "" : opRow["EncryptedOrderId"].ToString();
                 string orderid = opRow["OrderID"] == null ? "" : opRow["OrderID"].ToString();
                 string CostCenter = opRow["CostCenter"] == null ? "" : opRow["CostCenter"].ToString();
                 string TotalPrice = opRow["TotalPrice"] == null ? "" : opRow["TotalPrice"].ToString();
                 decimal subtotal = Decimal.Parse(TotalPrice);
                 DataSet dsstaringbudget = objrandb.RandBGetStartingBudget(CostCenter);
                 DataTable tblstaringbudget = dsstaringbudget.Tables[0];
                 if (tblstaringbudget.Rows.Count > 0)
                 {
                     DataRow startingbudgetRow = tblstaringbudget.Rows[0];
                     startingbudget = startingbudgetRow["startingbudget"] == null ? "" : startingbudgetRow["startingbudget"].ToString();
                     if (startingbudget != "" && startingbudget != "0.00" && startingbudget != "0")
                         dstartingbudget = Math.Round(Convert.ToDecimal(startingbudget), 2);
                     staringdatetime = startingbudgetRow["staringdatetime"] == null ? "" : startingbudgetRow["staringdatetime"].ToString();
                     Response.Write(staringdatetime);
                 }
                 DataSet dsab = objrandb.RandBGetAvailableBudgetCheckOut(CostCenter, dstartingbudget, staringdatetime, Convert.ToInt32(store_id), Convert.ToInt32(orderid));
                 DataTable tblab = dsab.Tables[0];
                 if (tblab.Rows.Count > 0)
                 {
                     DataRow ABRow = tblab.Rows[0];
                     availablebudget = ABRow["availablebudget"] == null ? "" : ABRow["availablebudget"].ToString();
                     if (availablebudget != "" && availablebudget != "0.00" && availablebudget != "0")
                         davailbudget = Math.Round(Convert.ToDecimal(availablebudget), 2);
                     Response.Write(orderid + "," + davailbudget.ToString() + "," );
                     //Response.Write(availablebudget + ";" + davailbudget);
                 }
                 total = total + subtotal;
                 //dremaining = davailbudget - total;
                 dremaining = davailbudget - total;
                 Response.Write(opid + "," + dremaining.ToString() + "," + oid + ",total:" + total);
                 objrandb.RandBUpdateOrderProduct(Convert.ToInt32(opid), dremaining, Convert.ToInt32(oid));//different from ooh because this time the ordercost already calculated by RandBGetAvailableBudget
             }
         }
     }
 }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     randb objOoh = new randb();
     randbXmpie objOohustore = new randbXmpie();
     int Uid = Convert.ToInt32(uStore.Common.BLL.CustomerInfo.Current.UserID.ToString());
     retailername.Text = "All";
     hiduserid.Value = Uid.ToString();
     string lastupdatedate = "";
     string startingbudget = "";
     string startingbudgetdate = "";
     decimal dstartingbudget = 0;
     DataSet dsearliestdate = objOoh.RandBGetEarliestStartingBudget(Uid);
     DataTable tblearliestdate = dsearliestdate.Tables[0];
     if (tblearliestdate.Rows.Count > 0)
     {
         DataRow EarliestRow = tblearliestdate.Rows[0];
         string startdate = EarliestRow["earliestdate"] == null ? "" : EarliestRow["earliestdate"].ToString();
         if (startdate != "")
         {
             string[] words = startdate.Split(' ');
             startingbudgetdate = words[0];
         }
     }
     DataSet dslastupdate = objOoh.RandBGetLastUpdate("", Uid);
     DataTable tbllastupdate = dslastupdate.Tables[0];
     if (tbllastupdate.Rows.Count > 0)
     {
         DataRow LastupdateRow = tbllastupdate.Rows[0];
         lastupdatedate = LastupdateRow["lastupdate"] == null ? "" : LastupdateRow["lastupdate"].ToString();
     }
     lastupdate.Text = lastupdatedate;
     //annualbudget.Text = dstartingbudget.ToString();
     //Response.Write(Uid.ToString());
     DataSet dsdistributor = objOoh.RandBGetAllRetailer(Uid);
     DataTable tbldistributor = dsdistributor.Tables[0];
     string htmldistributor = "<select id='ddldistributor' onchange='changeretailer(this.value);'><option value='0'>All</option>";
     int count = tbldistributor.Rows.Count;
     if (count > 0)
     {
         for (int c = 0; c < count; c++)
         {
             DataRow DistributorRow = tbldistributor.Rows[c];
             string retailer = DistributorRow["CostCenter"] == null ? "" : DistributorRow["CostCenter"].ToString();
             string retailerid = DistributorRow["CostCenterID"] == null ? "" : DistributorRow["CostCenterID"].ToString();
             htmldistributor = htmldistributor + "<option value='" + retailerid + "'>" + retailer + "</option>";
         }
     }
     htmldistributor = htmldistributor + "</select>";
     lbdistributor.Text = htmldistributor;
     var today = DateTime.Today.ToString("MM/dd/yyyy");
     var startdateformat = "";
     var previousDate = "";
     if (startingbudgetdate != "")
     {
         DateTime myDateTime = DateTime.Parse(startingbudgetdate);
         startdateformat = myDateTime.ToString("MM/dd/yyyy");
         StartDate.Value = startdateformat;
         previousDate = startdateformat;
     }
     else
     {
         DateTime.Now.Year.ToString();
         startdateformat = "01/01/" + DateTime.Now.Year.ToString();
         StartDate.Value = startdateformat;
         previousDate = startdateformat;
     }
     DataSet dsbudgetinfo = objOoh.RandBGetProductBudgetInfo("", "all", previousDate, today, Uid);
     DataTable tblbudgetinfo = dsbudgetinfo.Tables[0];
     int budgetcountrow = tblbudgetinfo.Rows.Count;
     string infohtml = "<table id='data' class='simpletable nopad'><thead><tr><th>Date</th><th>Retailer</th><th>Ordered by</th><th>Transaction</th><th>Order #</th><th>Item #</th><th>Description</th><th>Amount</th><th>Available Balance</th></tr></thead><tbody>";
     //Response.Write(budgetcountrow.ToString() + "," + previousDate + "," + today + "," + Uid);
     if (budgetcountrow > 0)
     {
         for (int b = 0; b < budgetcountrow; b++)
         {
             DataRow BudgetInfoRow = tblbudgetinfo.Rows[b];
             string orderedby = "";
             string costcentername = BudgetInfoRow["RetailerName"] == null ? "" : BudgetInfoRow["RetailerName"].ToString();
             string FirstName = BudgetInfoRow["FirstName"] == null ? "" : BudgetInfoRow["FirstName"].ToString();
             string LastName = BudgetInfoRow["LastName"] == null ? "" : BudgetInfoRow["LastName"].ToString();
             string amount = BudgetInfoRow["amount"] == null ? "" : BudgetInfoRow["amount"].ToString();
             string Transaction = BudgetInfoRow["Transaction"] == null ? "" : BudgetInfoRow["Transaction"].ToString();
             string Description = BudgetInfoRow["Description"] == null ? "" : BudgetInfoRow["Description"].ToString();
             string TransactionDate = BudgetInfoRow["TransactionDate"] == null ? "" : BudgetInfoRow["TransactionDate"].ToString();
             string OrderId = BudgetInfoRow["EncryptedOrderId"] == null ? "" : BudgetInfoRow["EncryptedOrderId"].ToString();
             string view = "";
             if (OrderId == "0")
                 OrderId = "-";
             string OrderProductID = BudgetInfoRow["OrderProductID"] == null ? "" : BudgetInfoRow["OrderProductID"].ToString();
             if (OrderProductID == "0")
                 OrderProductID = "-";
             else
                 view = "<a href='#' onclick=\"window.parent.location='../../OrderHistory' \">View</a>";
             decimal damount = 0;
             decimal dAvailableBudget = 0;
             string amountmoney = "";
             string AvailableBudgetmoney = "";
             string amountstyle = "";
             string AvailableBudgetstyle = "";
             if (amount != "0" && amount != "0.00" && amount != "" && amount != "0.00000")
                 damount = Math.Round(Convert.ToDecimal(amount), 2);
             if (damount < 0)
             {
                 amountmoney = "-$" + (damount * -1).ToString();
                 amountstyle = "style='color:red'";
             }
             else
                 amountmoney = "$" + damount.ToString();
             string AvailableBudget = BudgetInfoRow["AvailableBudget"] == null ? "" : BudgetInfoRow["AvailableBudget"].ToString();
             if (AvailableBudget != "0" && AvailableBudget != "0.00" && AvailableBudget != "")
                 dAvailableBudget = Math.Round(Convert.ToDecimal(AvailableBudget), 2);
             if (dAvailableBudget < 0)
             {
                 AvailableBudgetmoney = "-$" + (dAvailableBudget * -1).ToString();
                 AvailableBudgetstyle = "style='color:red'";
             }
             else
                 AvailableBudgetmoney = "$" + dAvailableBudget.ToString();
             if (Transaction == "Order")
                 orderedby = FirstName + " " + LastName;
             infohtml = infohtml + "<tr><td>" + TransactionDate + "</td><td>" + costcentername + "</td><td>" + orderedby + "</td><td>" + Transaction + "</td><td>" + OrderId + "</td><td>" + OrderProductID + "</td><td>" + Description + "</td>" +
                 "<td " + amountstyle + ">" + amountmoney + "</td><td " + AvailableBudgetstyle + ">" + AvailableBudgetmoney + "</td>";
         }
     }
     infohtml = infohtml + "</tbody></table>";
     tblbudget.InnerHtml = infohtml;
 }