protected Boolean PipePieceQty(out double min, out double max)
    {
        string matcode = txtAutoMatCode.Entries[0].Text;
        string min_qty = WebTools.DMinText("PIPE_LENGTH", "VIEW_PO_VENDOR_DATA", " WHERE MAT_CODE1='" + matcode + "'");
        string max_qty = WebTools.DMaxText("PIPE_LENGTH", "VIEW_PO_VENDOR_DATA", " WHERE MAT_CODE1='" + matcode + "'");

        if (string.IsNullOrEmpty(min_qty) || string.IsNullOrEmpty(max_qty))
        {
            min = 0;
            max = 1000;
            return(true);
        }

        //double min, max;
        min = Math.Ceiling(Convert.ToDouble(txtIssueQty.Text) / Convert.ToDouble(max_qty));
        max = Math.Floor(Convert.ToDouble(txtIssueQty.Text) / Convert.ToDouble(min_qty));



        if (Convert.ToDouble(txtPipePiece.Text) > max || Convert.ToDouble(txtPipePiece.Text) < min)
        {
            return(false);
        }

        return(true);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            dsGalvJobcardTableAdapters.PIP_COATING_TYPETableAdapter coating = new dsGalvJobcardTableAdapters.PIP_COATING_TYPETableAdapter();
            string coat_type_id = WebTools.DMaxText("COATING_TYPE_ID", "PIP_COATING_TYPE", " WHERE 1=1");

            if (string.IsNullOrEmpty(coat_type_id))
            {
                coat_type_id = "1";
            }
            else
            {
                coat_type_id = (decimal.Parse(coat_type_id) + 1).ToString();
            }

            coating.InsertQuery(decimal.Parse(coat_type_id), txtCoatingType.Text);
            Master.show_success("Item Added Successfully.");
            gridItems.Rebind();
        }
        catch (Exception ex)
        {
            Master.show_error(ex.Message);
        }
    }
示例#3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            string tc_id = "";

            if (txtAutoMTCCode.Entries.Count > 0)
            {
                string po_id = WebTools.GetExpr("PO_ID", "PRC_MAT_INSP", " MIR_ID='" + Session["popUp_MIR_ID"].ToString() + "'");
                tc_id = WebTools.GetExpr("TC_ID", "PIP_TEST_CARDS", " UPPER(TC_CODE) = '" + txtAutoMTCCode.Entries[0].Text.ToUpper() + "' and PO_ID = '" + po_id + "'");

                if (tc_id.Trim().Length == 0)
                {
                    //Register New MTC Code.
                    string sql = "INSERT INTO PIP_TEST_CARDS (PROJECT_ID, TC_CODE, PO_ID) VALUES ('" + Session["PROJECT_ID"].ToString() + "', '" +
                                 txtAutoMTCCode.Entries[0].Text.Trim() + "','" + po_id + "')";
                    WebTools.ExeSql(sql);

                    //Get TC_ID for New MTC Code
                    tc_id = WebTools.GetExpr("TC_ID", "PIP_TEST_CARDS", " UPPER(TC_CODE) = '" + txtAutoMTCCode.Entries[0].Text.ToUpper() + "'");
                }
            }
            else
            {
                Master.show_error("MTC Number cannot be blank.");
                return;
            }
            string mat_id = WebTools.GetExpr("MAT_ID", "PIP_MAT_STOCK", " MAT_CODE1='" + txtMatCode.Text + "'");


            string itemid = WebTools.GetExpr("ITEM_ID", "PIP_MAT_STOCK", " MAT_ID= " + mat_id);

            if (itemid != "19")
            {
                if (txtAcptQty.Text.ToString().IndexOf('.') > 0 || txtRcvQty.Text.ToString().IndexOf('.') > 0)
                {
                    Master.show_error("Selected Item cannot be in received in decimal Qty. <br/>Please Enter Integer Value.");
                    return;
                }
            }

            if (decimal.Parse(txtAcptQty.Text.ToString()) > decimal.Parse(txtRcvQty.Text.ToString()))
            {
                Master.show_error("Accepted quantity cannot be more than received qty. <br/>Please re-check and enter valid value.");
                return;
            }

            decimal?substore_id = null;
            if (ddlSubStorList.SelectedIndex > 0)
            {
                substore_id = decimal.Parse(ddlSubStorList.SelectedValue);
            }

            string heat_no = string.Empty;
            if (txtAutoHeatNo.Entries.Count == 0)
            {
                heat_no = "";
            }
            else
            {
                heat_no = txtAutoHeatNo.Entries[0].Text;
            }


            string sql1 = "";
            sql1  = "INSERT INTO PRC_MAT_INSP_DETAIL(MIR_ID, PO_ITEM, MIR_ITEM, MAT_ID, RCV_QTY, ACPT_QTY, HEAT_NO, PAINT_SYS, TC_ID, SUBSTORE_ID, REMARKS,CEVALUE, AS_PER_PL_QTY, EXC_QTY, SH_QTY, DAMAG_QTY) ";
            sql1 += "VALUES('" + Session["popUp_MIR_ID"].ToString() + "', '" + txtPOItemNO.Text + "','" + txtMIRItemNo.Text + "','" + mat_id + "','";
            sql1 += txtRcvQty.Text + "','" + txtAcptQty.Text + "','" + heat_no + "','" + txtPS.Text + "','" + tc_id + "','" + substore_id + "','";
            sql1 += txtRemarks.Text + "','', '', '" + txtExcessQty.Text + "','" + txtShortage.Text + "','" + txtDamage.Text + "')";
            // Master.show_success(sql1);
            WebTools.ExeSql(sql1);
            string query = string.Empty;
            try
            {
                //Update SRN No
                string   srn_no  = WebTools.GetExpr("SRN_NO", "PRC_MAT_INSP", " WHERE MIR_ID='" + Session["popUp_MIR_ID"].ToString() + "'");
                string   srn_no1 = string.Empty;
                string[] srn;

                if (srn_no.Contains(','))
                {
                    srn = srn_no.Split(',');
                    string po_id = WebTools.GetExpr("PO_ID", "PRC_MAT_INSP", " WHERE MIR_ID='" + Session["popUp_MIR_ID"].ToString() + "'");
                    string count = WebTools.CountExpr("DISTINCT SRN_NO", "PIP_PO_SPLIT_DETAIL", " WHERE PO_ID = '" + po_id + "' AND PO_ITEM = '" + txtPOItemNO.Text + "'");
                    if (decimal.Parse(count) == 1)
                    {
                        srn_no1 = WebTools.DMaxText("SRN_NO", "PIP_PO_SPLIT_DETAIL", " WHERE PO_ID = '" + po_id + "' AND PO_ITEM = '" + txtPOItemNO.Text + "'");
                    }
                    else
                    {
                        for (int i = 0; i < srn.Length; i++)
                        {
                            srn_no1 = WebTools.DMaxText("SRN_NO", "PIP_PO_SPLIT_DETAIL", " WHERE PO_ID = '" + po_id + "' AND PO_ITEM = '" + txtPOItemNO.Text + "' AND SRN_NO='" + srn[i] + "'");
                            if (srn_no1.Length > 0)
                            {
                                break;
                            }
                        }
                    }
                }
                else
                {
                    srn_no1 = srn_no;
                }

                query = "UPDATE PRC_MAT_INSP_DETAIL SET SRN_NO = '" + srn_no1 + "' WHERE MIR_ID = '" + Session["popUp_MIR_ID"].ToString() + "' " +
                        "  AND MIR_ITEM='" + txtMIRItemNo.Text + "'";

                WebTools.ExeSql(query);
            }
            catch (Exception ex)
            {
                //Don't do anything
            }
            Master.show_success(txtMatCode.Text + " Added Successfully.");
            //Master.show_success(query);
        }
        catch (Exception ex)
        {
            Master.show_error(ex.Message);
        }
    }