Exemplo n.º 1
0
    protected void txtOptionPartNo_TextChanged(object sender, EventArgs e)
    {
        DataTable dt     = new DataTable();
        DataTable dtTemp = new DataTable();

        fillOptionCategorygrid();
        bool b = true;

        if (txtOptionPartNo.Text != "")
        {
            for (int i = 0; i < txtOptionPartNo.Text.Length; i++)
            {
                char c = txtOptionPartNo.Text[i];

                dtTemp = ObjInvBOM.BOM_ById(StrCompId.ToString(), c.ToString());
                if (dtTemp.Rows.Count != 0)
                {
                    dt.Merge(dtTemp);
                    for (int j = 0; j < dt.Rows.Count; j++)
                    {
                        dtTemp = null;
                        dtTemp = new DataView(dt, "OptionCategoryId='" + dt.Rows[j]["OptionCategoryId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable();
                        if (dtTemp.Rows.Count == 2)
                        {
                            b = false;
                        }
                    }
                }
                else
                {
                    b = false;
                }
            }


            if (!b)
            {
                DisplayMessage("Invalid Part No");
                txtOptionPartNo.Text = "";
                txtOptionPartNo.Focus();
                fillOptionCategorygrid();
            }
            else
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    foreach (GridViewRow Row in gvOptionCategory.Rows)
                    {
                        RadioButtonList RdoList = (RadioButtonList)Row.FindControl("rdoOption");
                        for (int j = 0; j < RdoList.Items.Count; j++)
                        {
                            if (RdoList.Items[j].Value == dt.Rows[i]["TransId"].ToString())
                            {
                                RdoList.Items[j].Selected = true;
                            }
                        }
                    }
                }
            }
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        DateTime dt           = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", null);
        string   SubProductId = "0";
        string   ProductId    = new DataView(ObjInvProductMaster.GetProductMasterTrueAll(StrCompId.ToString()), "EProductName like '" + txtProductId.Text.Trim() + "%'", "", DataViewRowState.CurrentRows).ToTable().Rows[0]["ProductId"].ToString();

        if (txtSubProduct.Text != "")
        {
            if (txtSubProduct.Text != "0")
            {
                SubProductId = new DataView(ObjInvProductMaster.GetProductMasterTrueAll(StrCompId.ToString()), "EProductName like '" + txtSubProduct.Text.Trim() + "%'", "", DataViewRowState.CurrentRows).ToTable().Rows[0]["ProductId"].ToString();
            }
        }
        if (ProductId == "")
        {
            ProductId = "0";
        }
        if (SubProductId == "")
        {
            ProductId = "0";
        }

        if (txtOption.Text == "")
        {
            DisplayMessage("Enter Option");

            txtOption.Text = "";
            txtOption.Focus();
            return;
        }
        if (txtOptCatId.Text == "")
        {
            DisplayMessage("Enter Option Category");

            txtOptCatId.Text = "";
            txtOptCatId.Focus();
            return;
        }
        if (txtShortDesc.Text == "")
        {
            DisplayMessage("Enter Option Short Description");

            txtShortDesc.Text = "";
            txtShortDesc.Focus();
            return;
        }
        if (txtUnitPrice.Text == "")
        {
            DisplayMessage("Enter Unit Price");

            txtUnitPrice.Text = "";
            txtUnitPrice.Focus();
            return;
        }
        if (txtQty.Text == "")
        {
            DisplayMessage("Enter Quantity");

            txtQty.Text = "";
            txtQty.Focus();
            return;
        }

        string OptionCateId = string.Empty;

        if (txtOptCatId.Text != "")
        {
            OptionCateId = new DataView(ObjOpCate.GetOptionCategoryTrueAll(StrCompId.ToString()), "EName='" + txtOptCatId.Text.Trim() + "'", "", DataViewRowState.CurrentRows).ToTable().Rows[0]["OptionCategoryId"].ToString();
        }
        if (hdnDetailEdit.Value == "")
        {
            DataTable dtPS = new DataView(ObjInvBOM.BOM_All(StrCompId.ToString()), "OptionId='" + txtOption.Text.Trim() + "' and OptionCategoryId='" + OptionCateId.Trim() + "'", "", DataViewRowState.CurrentRows).ToTable();
            if (dtPS.Rows.Count != 0)
            {
                DisplayMessage("Option Id & Option Category Already Exists");
                txtOptCatId.Text = "";
                txtOption.Text   = "";
                txtOption.Focus();

                return;
            }


            ObjInvBOM.Insert_BOM(StrCompId.ToString(), "1", ProductId.Trim(), dt.ToString().Trim(), ddlTransType.SelectedValue.ToString().Trim(), SubProductId.ToString().Trim(), txtModelNo.Text.ToString().Trim(), txtOption.Text.ToString().Trim(), txtOptionDesc.Text.ToString().Trim(), txtShortDesc.Text.ToString().Trim(), OptionCateId.ToString().Trim(), txtUnitPrice.Text.ToString().Trim(), txtQty.Text.ToString().Trim(), "", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), StrUserId.ToString(), DateTime.Now.ToString(), StrUserId.ToString(), DateTime.Now.ToString());
        }
        else
        {
            DataTable dtPSID = new DataView(ObjInvBOM.BOM_ById(StrCompId.ToString(), hdnDetailEdit.Value.ToString()), "OptionId='" + txtOption.Text.Trim() + "' and OptionCategoryId='" + OptionCateId.Trim() + "'", "", DataViewRowState.CurrentRows).ToTable();
            if (dtPSID.Rows.Count == 0)
            {
                DataTable dtPS = new DataView(ObjInvBOM.BOM_All(StrCompId), "OptionId='" + txtOption.Text.Trim() + "' and OptionCategoryId='" + OptionCateId.Trim() + "'", "", DataViewRowState.CurrentRows).ToTable();
                if (dtPS.Rows.Count != 0)
                {
                    DisplayMessage("Option Id & Option Category Already Exists");
                    txtOptCatId.Text = "";
                    txtOption.Text   = "";
                    txtOption.Focus();

                    return;
                }
            }
            ObjInvBOM.Update_BOM(hdnDetailEdit.Value.ToString(), StrCompId.ToString().Trim(), "1", ProductId.ToString().Trim(), dt.ToString().Trim(), ddlTransType.SelectedValue.ToString().Trim(), SubProductId.ToString().Trim(), txtModelNo.Text.ToString().Trim(), txtOption.Text.ToString().Trim(), txtOptionDesc.Text.ToString().Trim(), txtShortDesc.Text.ToString().Trim(), OptionCateId.ToString().Trim(), txtUnitPrice.Text.ToString().Trim(), txtQty.Text.ToString().Trim(), "", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), StrUserId.ToString(), DateTime.Now.ToString());
        }
        ddlTransType.Enabled = false;
        txtDate.Enabled      = false;
        txtModelNo.Enabled   = false;
        txtProductId.Enabled = false;
        Reset_Child();
        fillGrid();
        pnlChlidGrid.Visible = true;
        rdoOption.Focus();
    }