Ejemplo n.º 1
0
    protected void btnCommand(object sender, CommandEventArgs e)
    {
        string cmdName = e.CommandName.ToString();
        string cmdArg = e.CommandArgument.ToString();

        switch (cmdName)
        {
            case "cmdAddItem":
                DataMaster vsLocal = new DataMaster();

                GridView gvMaterialItemList = (GridView)fvMaterialRecList.FindControl("gvMaterialItemList");
                TextBox tbMName = (TextBox)fvMaterialRecList.FindControl("tbMName");
                TextBox tbMDesc = (TextBox)fvMaterialRecList.FindControl("tbMDesc");
                TextBox tbQuantity = (TextBox)fvMaterialRecList.FindControl("tbQuantity");
                TextBox tbUnitName = (TextBox)fvMaterialRecList.FindControl("tbUnitName");
                TextBox tbRemark = (TextBox)fvMaterialRecList.FindControl("tbRemark");
                Label lblFMCode = (Label)fvMaterialRecList.FindControl("lblFMCode");
                Label lblSerialNo = (Label)fvMaterialRecList.FindControl("lblSerialNo");
                DropDownList ddlMCode = (DropDownList)fvMaterialRecList.FindControl("ddlMCode");
                LinkButton lbAddItem = (LinkButton)fvMaterialRecList.FindControl("lbAddItem");

                DetailMaterialRecordItemList itemLists = new DetailMaterialRecordItemList();
                itemLists.RegIDX = int.Parse(cmdArg.ToString());
                itemLists.MName = tbMName.Text;
                itemLists.MDesc = tbMDesc.Text;
                itemLists.RecQty = int.Parse(tbQuantity.Text);
                itemLists.UnitName = tbUnitName.Text;
                itemLists.RecRemark = tbRemark.Text;
                itemLists.CMCode = lblFMCode.Text;
                itemLists.SerialNo = lblSerialNo.Text;

                if (ViewState["vsItemLists"] != null)
                {
                    var temp = (((DataMaster)ViewState["vsItemLists"])).MaterialRecordItemList.ToList();
                    var cRow = temp.Count;
                    vsLocal.MaterialRecordItemList = new DetailMaterialRecordItemList[cRow + 1];
                    for (int i = 0; i < cRow; i++)
                    {
                        vsLocal.MaterialRecordItemList[i] = ((DataMaster)ViewState["vsItemLists"]).MaterialRecordItemList[i];
                    }
                    vsLocal.MaterialRecordItemList[cRow] = itemLists;
                }
                else
                {
                    vsLocal.MaterialRecordItemList = new DetailMaterialRecordItemList[1];
                    vsLocal.MaterialRecordItemList[0] = itemLists;
                }

                ViewState["vsItemLists"] = vsLocal;

                gvMaterialItemList.DataSource = vsLocal.MaterialRecordItemList;
                gvMaterialItemList.DataBind();

                //clear data
                ddlMCode.SelectedIndex = -1;
                tbMName.Text = String.Empty;
                tbMDesc.Text = String.Empty;
                tbQuantity.Text = String.Empty;
                tbRemark.Text = String.Empty;
                lblFMCode.Text = String.Empty;
                lblSerialNo.Text = String.Empty;
                lbAddItem.CommandArgument = "-1";
                break;
            case "cmdAddRec":
                gvMaterialRecList.Visible = false;
                fvMaterialRecList.Visible = true;
                lbAddRec.Visible = false;
                break;
        }
    }
Ejemplo n.º 2
0
    protected void gvRowCommand(object sender, GridViewCommandEventArgs e)
    {
        string cmdName = e.CommandName.ToString();
        string cmdArg  = e.CommandArgument.ToString();

        switch (cmdName)
        {
        case "cmdInsert":
            break;

        case "cmdEdit":
            gvMaterialRecList.Visible = false;
            fvMaterialRecList.Visible = true;
            lbAddRec.Visible          = false;

            DetailMaterialRecordList matRecord = new DetailMaterialRecordList();
            matRecord.RecIDX = int.Parse(cmdArg);
            dataMaster.MaterialRecordList    = new DetailMaterialRecordList[1];
            dataMaster.MaterialRecordList[0] = matRecord;
            dataMaster = serviceMaster.ActionDataMaster("materialrec", dataMaster, 20);
            // litTest.Text = HttpUtility.HtmlDecode(funcWeb.ConvertObjectToXml(dataMaster.MaterialRecordList[0]));
            ViewState["vsItemLists"] = dataMaster;    //.MaterialRecordItemList;
            setFormData(fvMaterialRecList, FormViewMode.Edit, dataMaster.MaterialRecordList);

            //print document
            //litOrderNo.Text = dataMaster.MaterialRecordList[0].RecNo;
            //litOrderDate.Text = dataMaster.MaterialRecordList[0].RecDate;
            //litFromSite.Text = dataMaster.MaterialRecordList[0].RecFromSiteName;
            //litToSite.Text = dataMaster.MaterialRecordList[0].RecToSiteName;

            litRecComment.Text = dataMaster.MaterialRecordList[0].RecComment;

            if (dataMaster.MaterialRecordItemList != null)
            {
                gvPrint.DataSource = dataMaster.MaterialRecordItemList;
                gvPrint.DataBind();
            }
            else
            {
                DetailMaterialRecordItemList itemLists = new DetailMaterialRecordItemList();
                itemLists.RegIDX = 0;
                dataMaster.MaterialRecordItemList    = new DetailMaterialRecordItemList[1];
                dataMaster.MaterialRecordItemList[0] = itemLists;
                gvPrint.DataSource = dataMaster.MaterialRecordItemList;
                gvPrint.DataBind();
            }

            //create row
            GridViewRow row = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);

            ////spanned cell that will span the columns I don't want to give the additional header
            //TableCell left = new TableHeaderCell();
            //left.ColumnSpan = 6;
            //row.Cells.Add(left);

            //spanned cell that will span the columns i want to give the additional header
            TableCell totals = new TableHeaderCell();
            totals.ColumnSpan = gvPrint.Columns.Count;
            totals.Text       = "<table style=\"width: 100%;\" class=\"printDoc\">";
            totals.Text      += "    <tbody>";
            totals.Text      += "        <tr style=\"line-height: 30px;\">";
            totals.Text      += "            <td style=\"width: 80%; text-align: center;\">THAI OBAYASHI CORP., LTD.</td>";
            totals.Text      += "            <td style=\"width: 20%;\">No. ";
            totals.Text      += dataMaster.MaterialRecordList[0].RecNo;
            totals.Text      += "        </tr>";
            totals.Text      += "        <tr style=\"line-height: 60px;\">";
            totals.Text      += "           <td style=\"width: 80%; text-align: center;\">";
            totals.Text      += "                <h3><b>ORDER SHEET</b></h3>";
            totals.Text      += "            </td>";
            totals.Text      += "            <td style=\"width: 20%;\">Date ";
            totals.Text      += dataMaster.MaterialRecordList[0].RecDate;
            totals.Text      += "        </tr>";
            totals.Text      += "    </tbody>";
            totals.Text      += "</table>";
            totals.Text      += "<table style=\"width: 100%;\">";
            totals.Text      += "    <tbody>";
            totals.Text      += "        <tr style=\"line-height: 50px;\">";
            totals.Text      += "            <td style=\"width: 50%;\">FROM : ";
            totals.Text      += dataMaster.MaterialRecordList[0].RecFromSiteName;
            totals.Text      += "            <td style=\"width: 50%;\">TO : ";
            totals.Text      += dataMaster.MaterialRecordList[0].RecToSiteName;
            totals.Text      += "        </tr>";
            totals.Text      += "    </tbody>";
            totals.Text      += "</table>";
            row.Cells.Add(totals);

            //Add the new row to the gridview as the master header row
            //A table is the only Control (index[0]) in a GridView
            ((Table)gvPrint.Controls[0]).Rows.AddAt(0, row);
            //print document
            break;

        case "cmdCancel":
            break;
        }
    }
Ejemplo n.º 3
0
    protected void gvRowCommand(object sender, GridViewCommandEventArgs e)
    {
        string cmdName = e.CommandName.ToString();
        string cmdArg = e.CommandArgument.ToString();

        switch (cmdName)
        {
            case "cmdInsert":
                break;
            case "cmdEdit":
                gvMaterialRecList.Visible = false;
                fvMaterialRecList.Visible = true;
                lbAddRec.Visible = false;

                DetailMaterialRecordList matRecord = new DetailMaterialRecordList();
                matRecord.RecIDX = int.Parse(cmdArg);
                dataMaster.MaterialRecordList = new DetailMaterialRecordList[1];
                dataMaster.MaterialRecordList[0] = matRecord;
                dataMaster = serviceMaster.ActionDataMaster("materialrec", dataMaster, 20);
                // litTest.Text = HttpUtility.HtmlDecode(funcWeb.ConvertObjectToXml(dataMaster.MaterialRecordList[0]));
                ViewState["vsItemLists"] = dataMaster;//.MaterialRecordItemList;
                setFormData(fvMaterialRecList, FormViewMode.Edit, dataMaster.MaterialRecordList);

                //print document
                //litOrderNo.Text = dataMaster.MaterialRecordList[0].RecNo;
                //litOrderDate.Text = dataMaster.MaterialRecordList[0].RecDate;
                //litFromSite.Text = dataMaster.MaterialRecordList[0].RecFromSiteName;
                //litToSite.Text = dataMaster.MaterialRecordList[0].RecToSiteName;

                litRecComment.Text = dataMaster.MaterialRecordList[0].RecComment;

                if (dataMaster.MaterialRecordItemList != null)
                {
                    gvPrint.DataSource = dataMaster.MaterialRecordItemList;
                    gvPrint.DataBind();
                }
                else
                {
                    DetailMaterialRecordItemList itemLists = new DetailMaterialRecordItemList();
                    itemLists.RegIDX = 0;
                    dataMaster.MaterialRecordItemList = new DetailMaterialRecordItemList[1];
                    dataMaster.MaterialRecordItemList[0] = itemLists;
                    gvPrint.DataSource = dataMaster.MaterialRecordItemList;
                    gvPrint.DataBind();
                }

                //create row
                GridViewRow row = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);

                ////spanned cell that will span the columns I don't want to give the additional header
                //TableCell left = new TableHeaderCell();
                //left.ColumnSpan = 6;
                //row.Cells.Add(left);

                //spanned cell that will span the columns i want to give the additional header
                TableCell totals = new TableHeaderCell();
                totals.ColumnSpan = gvPrint.Columns.Count;
                totals.Text = "<table style=\"width: 100%;\" class=\"printDoc\">";
                totals.Text += "    <tbody>";
                totals.Text += "        <tr style=\"line-height: 30px;\">";
                totals.Text += "            <td style=\"width: 80%; text-align: center;\">THAI OBAYASHI CORP., LTD.</td>";
                totals.Text += "            <td style=\"width: 20%;\">No. ";
                totals.Text += dataMaster.MaterialRecordList[0].RecNo;
                totals.Text += "        </tr>";
                totals.Text += "        <tr style=\"line-height: 60px;\">";
                totals.Text += "           <td style=\"width: 80%; text-align: center;\">";
                totals.Text += "                <h3><b>ORDER SHEET</b></h3>";
                totals.Text += "            </td>";
                totals.Text += "            <td style=\"width: 20%;\">Date ";
                totals.Text += dataMaster.MaterialRecordList[0].RecDate;
                totals.Text += "        </tr>";
                totals.Text += "    </tbody>";
                totals.Text += "</table>";
                totals.Text += "<table style=\"width: 100%;\">";
                totals.Text += "    <tbody>";
                totals.Text += "        <tr style=\"line-height: 50px;\">";
                totals.Text += "            <td style=\"width: 50%;\">FROM : ";
                totals.Text += dataMaster.MaterialRecordList[0].RecFromSiteName;
                totals.Text += "            <td style=\"width: 50%;\">TO : ";
                totals.Text += dataMaster.MaterialRecordList[0].RecToSiteName;
                totals.Text += "        </tr>";
                totals.Text += "    </tbody>";
                totals.Text += "</table>";
                row.Cells.Add(totals);

                //Add the new row to the gridview as the master header row
                //A table is the only Control (index[0]) in a GridView
                ((Table)gvPrint.Controls[0]).Rows.AddAt(0, row);
                //print document
                break;
            case "cmdCancel":
                break;
        }
    }
Ejemplo n.º 4
0
    protected void btnCommand(object sender, CommandEventArgs e)
    {
        string cmdName = e.CommandName.ToString();
        string cmdArg  = e.CommandArgument.ToString();

        switch (cmdName)
        {
        case "cmdAddItem":
            DataMaster vsLocal = new DataMaster();

            GridView     gvMaterialItemList = (GridView)fvMaterialRecList.FindControl("gvMaterialItemList");
            TextBox      tbMName            = (TextBox)fvMaterialRecList.FindControl("tbMName");
            TextBox      tbMDesc            = (TextBox)fvMaterialRecList.FindControl("tbMDesc");
            TextBox      tbQuantity         = (TextBox)fvMaterialRecList.FindControl("tbQuantity");
            TextBox      tbUnitName         = (TextBox)fvMaterialRecList.FindControl("tbUnitName");
            TextBox      tbRemark           = (TextBox)fvMaterialRecList.FindControl("tbRemark");
            Label        lblFMCode          = (Label)fvMaterialRecList.FindControl("lblFMCode");
            Label        lblSerialNo        = (Label)fvMaterialRecList.FindControl("lblSerialNo");
            DropDownList ddlMCode           = (DropDownList)fvMaterialRecList.FindControl("ddlMCode");
            LinkButton   lbAddItem          = (LinkButton)fvMaterialRecList.FindControl("lbAddItem");

            DetailMaterialRecordItemList itemLists = new DetailMaterialRecordItemList();
            itemLists.RegIDX    = int.Parse(cmdArg.ToString());
            itemLists.MName     = tbMName.Text;
            itemLists.MDesc     = tbMDesc.Text;
            itemLists.RecQty    = int.Parse(tbQuantity.Text);
            itemLists.UnitName  = tbUnitName.Text;
            itemLists.RecRemark = tbRemark.Text;
            itemLists.CMCode    = lblFMCode.Text;
            itemLists.SerialNo  = lblSerialNo.Text;

            if (ViewState["vsItemLists"] != null)
            {
                var temp = (((DataMaster)ViewState["vsItemLists"])).MaterialRecordItemList.ToList();
                var cRow = temp.Count;
                vsLocal.MaterialRecordItemList = new DetailMaterialRecordItemList[cRow + 1];
                for (int i = 0; i < cRow; i++)
                {
                    vsLocal.MaterialRecordItemList[i] = ((DataMaster)ViewState["vsItemLists"]).MaterialRecordItemList[i];
                }
                vsLocal.MaterialRecordItemList[cRow] = itemLists;
            }
            else
            {
                vsLocal.MaterialRecordItemList    = new DetailMaterialRecordItemList[1];
                vsLocal.MaterialRecordItemList[0] = itemLists;
            }

            ViewState["vsItemLists"] = vsLocal;

            gvMaterialItemList.DataSource = vsLocal.MaterialRecordItemList;
            gvMaterialItemList.DataBind();

            //clear data
            ddlMCode.SelectedIndex    = -1;
            tbMName.Text              = String.Empty;
            tbMDesc.Text              = String.Empty;
            tbQuantity.Text           = String.Empty;
            tbRemark.Text             = String.Empty;
            lblFMCode.Text            = String.Empty;
            lblSerialNo.Text          = String.Empty;
            lbAddItem.CommandArgument = "-1";
            break;

        case "cmdAddRec":
            gvMaterialRecList.Visible = false;
            fvMaterialRecList.Visible = true;
            lbAddRec.Visible          = false;
            break;
        }
    }