示例#1
0
        private void ComputeIfBidTenderIs2MAbove()
        {
            BidTenderTransaction bt = new BidTenderTransaction();

            bt.MarkIf2MAbove(connstring, ViewState[Constant.SESSION_BIDREFNO].ToString().Trim(), ViewState[Constant.SESSION_USERID].ToString().Trim());
        }
示例#2
0
        private void ShowBidTenders()
        {
            #region Code for preparing the DataTable
            BidTenderTransaction bt = new BidTenderTransaction();
            int       count         = 0;
            DataTable dtTenders     = bt.GetBidTenders(connstring, ViewState[Constant.SESSION_BIDREFNO].ToString().Trim(), ViewState[Constant.SESSION_USERID].ToString().Trim(), ref count);
            Session["Mode_BidTenders"] = ((count == 0) ? "Add" : "Edit");

            //Create an instance of DataTable
            DataTable  dt   = new DataTable();
            DataColumn dcol = new DataColumn(ID, typeof(System.String));
            dcol = new DataColumn("ITEM", typeof(System.String));
            dt.Columns.Add(dcol);
            dcol = new DataColumn("AMOUNT", typeof(System.String));
            dt.Columns.Add(dcol);
            dcol = new DataColumn("TENDERDATE", typeof(System.String));
            dt.Columns.Add(dcol);
            dcol = new DataColumn("BIDTENDERNO", typeof(System.String));
            dt.Columns.Add(dcol);
            dcol = new DataColumn("BIDDETAILNO", typeof(System.String));
            dt.Columns.Add(dcol);

            //Now add data for dynamic columns
            for (int i = 0; i < dtTenders.Rows.Count; i++)
            {
                //Create a new row
                DataRow drow = dt.NewRow();
                drow["ITEM"]        = dtTenders.Rows[i]["ITEM"].ToString().Trim();
                drow["AMOUNT"]      = ((i == dtTenders.Rows.Count - 1) ? "Last|" + dtTenders.Rows[i]["AMOUNT"].ToString().Trim() : dtTenders.Rows[i]["AMOUNT"].ToString().Trim());
                drow["TENDERDATE"]  = "DATE|" + dtTenders.Rows[i]["TENDERDATEMONTH"].ToString().Trim() + "/" + dtTenders.Rows[i]["TENDERDATEDAY"].ToString().Trim() + "/" + dtTenders.Rows[i]["TENDERDATEYEAR"].ToString().Trim();
                drow["BIDTENDERNO"] = dtTenders.Rows[i]["BIDTENDERNO"].ToString().Trim();
                drow["BIDDETAILNO"] = dtTenders.Rows[i]["BIDDETAILNO"].ToString().Trim();
                dt.Rows.Add(drow);
            }

            IOClass IO = new IOClass();
            IO.WriteIndexToFile(dtTenders.Rows.Count.ToString().Trim(), ViewState[Constant.SESSION_USERID].ToString().Trim());

            BidTenderGeneral bidtender = new BidTenderGeneral();
            bidtender = bt.QueryBidTendersGeneral(ViewState[Constant.SESSION_BIDREFNO].ToString().Trim(), ViewState[Constant.SESSION_USERID].ToString().Trim());
            Session["Mode_BidTendersGeneral"] = bidtender.Mode_BidTendersGeneral.ToString().Trim();

            DataRow drow1 = dt.NewRow();
            drow1["ITEM"]       = "Discount";
            drow1["AMOUNT"]     = "Discount|" + bidtender.Discount.ToString().Trim();
            drow1["TENDERDATE"] = "Discount|NONE";
            dt.Rows.Add(drow1);
            //DataRow drow2 = dt.NewRow();
            //drow2["ITEM"] = "Total Cost";
            //drow2["AMOUNT"] = "Total Cost|" + bidtender.TotalCost.ToString().Trim();
            //drow2["TENDERDATE"] = "Total Cost|NONE";
            //dt.Rows.Add(drow2);
            DataRow drow3 = dt.NewRow();
            drow3["ITEM"]       = "Delivery Cost";
            drow3["AMOUNT"]     = "Delivery Cost|" + bidtender.DeliveryCost.ToString().Trim();
            drow3["TENDERDATE"] = "Delivery Cost|NONE";
            dt.Rows.Add(drow3);
            //DataRow drow4 = dt.NewRow();
            //drow4["ITEM"] = "Total Extended Cost";
            //drow4["AMOUNT"] = "Total Extended Cost|" + bidtender.TotalExtendedCost.ToString().Trim();
            //drow4["TENDERDATE"] = "Total Extended Cost|NONE";
            //dt.Rows.Add(drow4);
            DataRow drow5 = dt.NewRow();
            drow5["ITEM"]       = "Incoterm";
            drow5["AMOUNT"]     = "Incoterm|" + bidtender.Incoterm.ToString().Trim();
            drow5["TENDERDATE"] = "Incoterm|NONE";
            dt.Rows.Add(drow5);
            DataRow drow6 = dt.NewRow();
            drow6["ITEM"]       = "Payment Terms";
            drow6["AMOUNT"]     = "Payment Terms|" + bidtender.PaymentTerms.ToString().Trim();
            drow6["TENDERDATE"] = "Payment Terms|NONE";
            dt.Rows.Add(drow6);
            DataRow drow7 = dt.NewRow();
            drow7["ITEM"]       = "Warranty";
            drow7["AMOUNT"]     = "Warranty|" + bidtender.Warranty.ToString().Trim();
            drow7["TENDERDATE"] = "Warranty|NONE";
            dt.Rows.Add(drow7);
            DataRow drow8 = dt.NewRow();
            drow8["ITEM"]       = "Remarks";
            drow8["AMOUNT"]     = "Remarks|" + bidtender.Remarks.ToString().Trim();
            drow8["TENDERDATE"] = "Remarks|NONE";
            dt.Rows.Add(drow8);

            #endregion

            //Iterate through the columns of the datatable to set the data bound field dynamically.
            foreach (DataColumn col in dt.Columns)
            {
                //Declare the bound field and allocate memory for the bound field.
                CustomBoundField bfield = new CustomBoundField();
                //Initalize the DataField value.
                bfield.DataField            = col.ColumnName;
                bfield.HeaderStyle.CssClass = "itemDetails_th";
                switch (col.ColumnName)
                {
                case "ITEM":
                    //Initialize the HeaderText field value.
                    bfield.HeaderText         = "Item";
                    bfield.HeaderType         = Constant.HEADER_TYPE_LABEL.ToString().Trim();
                    bfield.ItemStyle.CssClass = "itemDetails_td";
                    bfield.DataField          = "ITEM";
                    bfield.VendorId           = Session[Constant.SESSION_USERID].ToString().Trim();
                    bfield.Editable           = false;
                    bfield.Date      = false;
                    bfield.Label2    = false;
                    bfield.Label4    = true;
                    bfield.LabelDate = false;
                    break;

                case "AMOUNT":
                    //Initialize the HeaderText field value.
                    bfield.HeaderText         = "Bids";
                    bfield.HeaderType         = Constant.HEADER_TYPE_LABEL.ToString().Trim();
                    bfield.DataField          = "AMOUNT";
                    bfield.ItemStyle.CssClass = "valueGridItem";
                    bfield.VendorId           = Session[Constant.SESSION_USERID].ToString().Trim();
                    bfield.Editable           = false;
                    bfield.Date      = false;
                    bfield.Label2    = true;
                    bfield.Label4    = false;
                    bfield.LabelDate = false;
                    break;

                case "TENDERDATE":
                    //Initialize the HeaderText field value.
                    bfield.HeaderText         = "Delivery Date";
                    bfield.HeaderType         = Constant.HEADER_TYPE_LABEL.ToString().Trim();
                    bfield.ItemStyle.CssClass = "valueGridItem";
                    bfield.DataField          = "TENDERDATE";
                    bfield.VendorId           = Session[Constant.SESSION_USERID].ToString().Trim();
                    bfield.Editable           = false;
                    bfield.Date      = false;
                    bfield.Label2    = false;
                    bfield.Label4    = false;
                    bfield.LabelDate = true;
                    break;

                case "BIDTENDERNO":
                    //Initialize the HeaderText field value.
                    bfield.HeaderText = col.ColumnName;
                    bfield.Visible    = false;
                    bfield.HeaderType = Constant.HEADER_TYPE_LABEL.ToString().Trim();
                    bfield.DataField  = "BIDTENDERNO";
                    bfield.Editable   = false;
                    bfield.Date       = false;
                    break;

                case "BIDDETAILNO":
                    //Initialize the HeaderText field value.
                    bfield.HeaderText = col.ColumnName;
                    bfield.Visible    = false;
                    bfield.HeaderType = Constant.HEADER_TYPE_LABEL.ToString().Trim();
                    bfield.DataField  = "BIDDETAILNO";
                    bfield.Editable   = false;
                    bfield.Date       = false;
                    break;
                }
                //Add the newly created bound field to the GridView.
                gvBids.Columns.Add(bfield);
            }

            gvBids.DataSource = dt;
            gvBids.DataBind();
        }
示例#3
0
        private void SaveBidTender(string Status)
        {
            #region GetBidTenderCount
            IOClass IO   = new IOClass();
            int     line = IO.GetTenderCount(ViewState[Constant.SESSION_USERID].ToString().Trim());
            int     i    = 0;
            #endregion
            #region Declare Variables

            double dblTotalAmount       = 0;
            double dblTotalCost         = 0;
            double dblTotalExtendedCost = 0;
            string vTotalCost           = "";
            string vTotalExtendedCost   = "";
            string vAmount       = "";
            string vDiscount     = "";
            string vDeliveryCost = "";
            string vIncoterm     = "";
            string vPayment      = "";
            string vWarranty     = "";
            string vRemarks      = "";

            #endregion
            #region GetValuesFromRowsAndSave

            foreach (GridViewRow gvr in gvBidDetails2.Rows)
            {
                if (i < line)
                {
                    vAmount = ((TextBox)gvr.Cells[1].Controls[0]).Text;
                    if (vAmount != "")
                    {
                        dblTotalAmount = dblTotalAmount + Convert.ToDouble(vAmount);
                    }
                    string vDay         = ((TextBox)gvr.Cells[2].Controls[1]).Text;
                    string vMonth       = ((DropDownList)gvr.Cells[2].Controls[0]).SelectedItem.Value;
                    string vYear        = ((TextBox)gvr.Cells[2].Controls[2]).Text;
                    string vBidTenderNo = ((Label)gvr.Cells[3].Controls[0]).Text;
                    string vBidDetailNo = ((Label)gvr.Cells[4].Controls[0]).Text;
                    //vBidTenderNo = SaveTenderToDataBase(vBidDetailNo, vAmount, vMonth + '/' + vDay + '/' + vYear, ViewState[Constant.SESSION_USERID].ToString().Trim(), vBidTenderNo, "0");
                }
                else
                {
                    switch (i - line)
                    {
                    case 0:
                        vDiscount = ((TextBox)gvr.Cells[1].Controls[1]).Text;
                        if (vDiscount != "")
                        {
                            dblTotalCost = dblTotalAmount - Convert.ToDouble(vDiscount);
                        }
                        else
                        {
                            dblTotalCost = dblTotalAmount;
                        }
                        break;

                    case 1:
                        vTotalCost = ((TextBox)gvr.Cells[1].Controls[0]).Text;
                        vTotalCost = dblTotalCost.ToString().Trim();
                        break;

                    case 2:
                        vDeliveryCost = ((TextBox)gvr.Cells[1].Controls[0]).Text;
                        if (vDeliveryCost != "")
                        {
                            dblTotalExtendedCost = dblTotalCost + Convert.ToDouble(vDeliveryCost);
                        }
                        else
                        {
                            dblTotalExtendedCost = dblTotalCost;
                        }

                        break;

                    case 3:
                        vTotalExtendedCost = ((TextBox)gvr.Cells[1].Controls[0]).Text;
                        vTotalExtendedCost = dblTotalExtendedCost.ToString().Trim();
                        break;

                    case 4:
                        vIncoterm = ((DropDownList)gvr.Cells[1].Controls[0]).SelectedItem.Value;
                        break;

                    case 5:
                        vPayment = ((TextBox)gvr.Cells[1].Controls[0]).Text;
                        break;

                    case 6:
                        vWarranty = ((TextBox)gvr.Cells[1].Controls[0]).Text;
                        break;

                    case 7:
                        vRemarks = ((TextBox)gvr.Cells[1].Controls[0]).Text;
                        break;
                    }
                }
                i++;
            }

            BidTenderTransaction bt = new BidTenderTransaction();
            if (Session["Mode_BidTendersGeneral"].ToString().Trim() != "Edit")
            {
                bt.InsertBidTenderGeneralToDataBase(connstring, ViewState["BidRefNo"].ToString().Trim(), ViewState[Constant.SESSION_USERID].ToString().Trim(), ddlPreferredCurrency.SelectedItem.Value, vDiscount, vTotalCost, vDeliveryCost, vTotalExtendedCost, vIncoterm, vPayment, vWarranty, vRemarks, Status);
                Session["Mode_BidTendersGeneral"] = "Edit";
            }
            else
            {
                bt.UpdateBidTenderGeneralToDataBase(ViewState["BidRefNo"].ToString().Trim(), ViewState[Constant.SESSION_USERID].ToString().Trim(), ddlPreferredCurrency.SelectedItem.Value, vDiscount, vTotalCost, vDeliveryCost, vTotalExtendedCost, vIncoterm, vPayment, vWarranty, vRemarks, Status);
            }
            //SaveComment();
            #endregion
        }