protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            decimal mat_id = db_lookup.MAT_ID(txtMatCode.Text, Decimal.Parse(Session["PROJECT_ID"].ToString()));
            if (mat_id == -1)
            {
                Master.ShowWarn("There are two materials with the same code! try to use the unique one.");
                return;
            }
            else if (mat_id == 0)
            {
                Master.ShowWarn("Material Code not found!");
                return;
            }
            //if (WebTools.GetExpr("HEAT_NO", "PIP_HEAT_NO", " WHERE HEAT_NO='" + txtHeatNo.Text +
            //    "' AND PROJECT_ID=" + Session["PROJECT_ID"].ToString()) == "")
            //{
            //    Master.ShowWarn("Heat number not found!");
            //    return;
            //}
            //else
            //{
            //    //Find TC_CODE for selected heat number
            //}

            int     irn_id     = int.Parse(ddlIRN.SelectedValue);
            string  po_item    = txtPoItem.Text;
            decimal bal_to_rec = decimal.Parse(WebTools.GetExpr("BAL_TO_RECV", "VIEW_IRN_BAL_TO_RECV", " WHERE IRN_ID=" + irn_id + " AND PO_ITEM='" + po_item + "'"));
            if (decimal.Parse(txtQty.Text) > bal_to_rec)
            {
                RadWindowManager1.RadAlert("Receive Quantity cannot be more than IRN Qty:" + bal_to_rec, 300, 150, "Warning", "");
                return;
            }
            VIEW_ADAPTER_MAT_RCV_DETAILTableAdapter items = new VIEW_ADAPTER_MAT_RCV_DETAILTableAdapter();
            string pieces = txtPieces.Text;
            if (pieces == "N/A" || pieces == "")
            {
                pieces = "0";
            }

            items.InsertQuery(Decimal.Parse(Request.QueryString["MAT_RCV_ID"]),
                              mat_id, Decimal.Parse(txtQty.Text),
                              null, null,
                              txtPoItem.Text, txtRemarks.Text,
                              txtMrItem.Text, txtCableDrumNo.Text, decimal.Parse(ddlIRN.SelectedValue), decimal.Parse(pieces));
            Master.ShowMessage(txtMatCode.Text + " added.");
        }
        catch (Exception ex)
        {
            Master.ShowWarn(ex.Message);
        }
    }
Exemplo n.º 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        VIEW_ADAPTER_MAT_RCV_DETAILTableAdapter mrr = new VIEW_ADAPTER_MAT_RCV_DETAILTableAdapter();
        decimal mat_id;
        string  mat_code1;
        string  bal_to_recv, mr_item;
        string  rel_qty;
        string  irn_id = "";

        try
        {
            foreach (GridDataItem item in itemsGrid.SelectedItems)
            {
                mat_code1 = item["MAT_CODE1"].Text;
                //mat_id = WebTools.GetMatId(mat_code1, decimal.Parse(Session["PROJECT_ID"].ToString()));
                mat_id = decimal.Parse(WebTools.GetExpr("MAT_ID", "PIP_MAT_STOCK", " WHERE MAT_CODE1='" + mat_code1 + "'"));
                //irn_id = WebTools.GetExpr("IRN_ID", "PIP_MAT_RECEIVE_IRN", " WHERE MAT_RCV_ID = '" + Request.QueryString["MAT_RCV_ID"].ToString()+ "'");
                irn_id      = WebTools.GetExpr("IRN_ID", "PIP_PO_IRN", " WHERE IRN_NO = '" + item["IRN_NO"].Text + "'");
                bal_to_recv = WebTools.GetExpr("BAL_TO_RECV", "VIEW_IRN_BAL_TO_RECV", " WHERE IRN_ID = '" + irn_id + "' AND PO_ITEM='" + item["PO_ITEM"].Text +
                                               "' AND MAT_ID='" + mat_id + "'");
                //bal_to_recv = (item["BAL_TO_RECV"].FindControl("BAL_TO_RECVLabel") as TextBox).Text;
                mr_item = WebTools.CountExpr("(1)", "PIP_MAT_RECEIVE_DETAIL", " WHERE MAT_RCV_ID='" + Request.QueryString["MAT_RCV_ID"].ToString() + "'");
                string RECV_QTY = (item["BAL_TO_RECV"].FindControl("BAL_TO_RECVLabel") as TextBox).Text;


                if ((decimal.Parse(item["RELEASE_QTY"].Text) - decimal.Parse(item["RECV_QTY"].Text)) < decimal.Parse(bal_to_recv))
                {
                    Master.ShowError("Receive Quantity cannot be more than release qty. ");
                    return;
                }
                string pieces = (item["BAL_TO_RECV_PIECES"].FindControl("BAL_TO_RECV_PIECESLabel") as TextBox).Text;

                if (pieces == "N/A" || pieces == "")
                {
                    pieces = "0";
                }
                mrr.InsertQuery(decimal.Parse(Request.QueryString["MAT_RCV_ID"]), mat_id, decimal.Parse(RECV_QTY), null, null,
                                item["PO_ITEM"].Text, null, (Decimal.Parse(mr_item) + 1).ToString(), null, (decimal.Parse(item["IRN_ID"].Text)), decimal.Parse(pieces));
            }
            Master.ShowMessage("Selected Items Added to MRR.");
        }
        catch (Exception ex)
        {
            Master.ShowError(ex.Message);
        }
        finally {
            itemsGrid.Rebind();
        }
    }