Esempio n. 1
0
        public void BindProductDetails(long OrderID, int Sequence, long UserID)
        {
            CustomProfile      profile    = CustomProfile.GetProfile();
            iPartRequestClient objService = new iPartRequestClient();
            int IsPriceEdit = objService.IsPriceEditYN(OrderID, UserID, profile.DBConnection._constr);
            int IsSkuChange = objService.IsSkuChangeYN(OrderID, UserID, profile.DBConnection._constr);

            if (IsPriceEdit == 1)
            {
                txtPrc.Disabled = false;
            }
            else
            {
                txtPrc.Disabled = true;
            }
            if (IsSkuChange == 1)
            {
                txtReqQty.Disabled = false;
            }
            else
            {
                txtReqQty.Disabled = true;
            }

            DataSet ds = new DataSet();

            ds = objService.GetProductOfOrder(OrderID, Sequence, profile.DBConnection._constr);
            txtProductCode.Text        = ds.Tables[0].Rows[0]["Prod_Code"].ToString();
            txtProductName.Text        = ds.Tables[0].Rows[0]["Prod_Name"].ToString();
            txtProductDescription.Text = ds.Tables[0].Rows[0]["Prod_Description"].ToString();
            txtMOQ.Text          = ds.Tables[0].Rows[0]["moq"].ToString();
            txtCurrentStock.Text = ds.Tables[0].Rows[0]["AvailableBalance"].ToString();
            txtReserveStock.Text = ds.Tables[0].Rows[0]["ResurveQty"].ToString();
            //   txtReqQty.Value = ds.Tables[0].Rows[0]["OrderQty"].ToString();
            txtOrderQty.Text = ds.Tables[0].Rows[0]["OrderQty"].ToString();
            txtPrc.Value     = ds.Tables[0].Rows[0]["Price"].ToString();
            //txtPrice.Text = ds.Tables[0].Rows[0]["Price"].ToString();
            txtTotal.Text = ds.Tables[0].Rows[0]["Total"].ToString();
            int     ProdID = int.Parse(ds.Tables[0].Rows[0]["SkuId"].ToString()); hdnSelectedProduct.Value = ProdID.ToString();
            DataSet dsUOM  = new DataSet();

            dsUOM             = objService.GetUOMofSelectedProduct(ProdID, profile.DBConnection._constr);
            ddlUOM.DataSource = dsUOM;
            ddlUOM.DataBind();
            //ddlUOM.SelectedValue =ds.Tables[0].Rows[0]["UOMID"].ToString();
            ddlUOM.SelectedIndex = ddlUOM.Items.IndexOf(ddlUOM.Items.FindByValue(ds.Tables[0].Rows[0]["UOMID"].ToString()));
            DataSet dsUOMSelPrd = new DataSet();

            dsUOMSelPrd = objService.GetUOMofSelectedProduct(ProdID, profile.DBConnection._constr);
            int SelInd = 0;

            SelInd = ddlUOM.SelectedIndex;
            decimal SelectedQty = decimal.Parse(dsUOMSelPrd.Tables[0].Rows[SelInd]["Quantity"].ToString());
            decimal UserQty     = decimal.Parse(ds.Tables[0].Rows[0]["OrderQty"].ToString());

            txtReqQty.Value = Convert.ToString(UserQty / SelectedQty);
        }
        protected void Grid1_OnRowDataBound(object sender, Obout.Grid.GridRowEventArgs e)
        {
            iPartRequestClient objService = new iPartRequestClient();
            CustomProfile      profile    = CustomProfile.GetProfile();

            try
            {
                if (e.Row.RowType == Obout.Grid.GridRowType.DataRow)
                {
                    //Obout.Grid.GridDataControlFieldCell cell = e.Row.Cells[6] as Obout.Grid.GridDataControlFieldCell;
                    //Obout.Grid.GridDataControlFieldCell cell = e.Row.Cells[7] as Obout.Grid.GridDataControlFieldCell;
                    Obout.Grid.GridDataControlFieldCell cell = e.Row.Cells[8] as Obout.Grid.GridDataControlFieldCell;

                    DropDownList ddl    = cell.FindControl("ddlUOM") as DropDownList;
                    HiddenField  hdnUOM = cell.FindControl("hdnMyUOM") as HiddenField;
                    //Label rowQtySpn = e.Row.Cells[9].FindControl("rowQtyTotal") as Label;
                    Label rowQtySpn = e.Row.Cells[10].FindControl("rowQtyTotal") as Label;

                    //TextBox txtUsrQty = e.Row.Cells[6].FindControl("txtUsrQty") as TextBox;
                    TextBox txtUsrQty = e.Row.Cells[7].FindControl("txtUsrQty") as TextBox;

                    int     ProdID = Convert.ToInt32(e.Row.Cells[0].Text);
                    decimal moq    = Convert.ToDecimal(e.Row.Cells[6].Text);

                    TextBox txtUsrPrice   = e.Row.Cells[11].FindControl("txtUsrPrice") as TextBox;
                    Label   rowPriceTotal = e.Row.Cells[12].FindControl("rowPriceTotal") as Label;

                    DataSet dsUOM = new DataSet();
                    dsUOM = objService.GetUOMofSelectedProduct(ProdID, profile.DBConnection._constr);

                    ddl.DataSource     = dsUOM;
                    ddl.DataTextField  = "Description";
                    ddl.DataValueField = "UMOGroup";
                    ddl.DataBind();

                    decimal SelectedQty = 0, SelectedUOM = 0;
                    decimal Price = decimal.Parse(txtUsrPrice.Text.ToString());

                    //ddl.SelectedValue = e.Row.Cells[6].Text;
                    if (hdnTemplateID.Value != "")
                    {
                        long   TemplID     = Convert.ToInt64(hdnTemplateID.Value);
                        string selectedUom = objService.GetSelectedUomTemplate(TemplID, ProdID, profile.DBConnection._constr);
                        ddl.SelectedIndex  = ddl.Items.IndexOf(ddl.Items.FindByValue(selectedUom.ToString()));
                        rowQtySpn.Text     = txtUsrQty.Text;
                        rowPriceTotal.Text = e.Row.Cells[12].Text;
                    }
                    else
                    {
                        ddl.SelectedIndex = 2;

                        SelectedQty = decimal.Parse(dsUOM.Tables[0].Rows[2]["Quantity"].ToString());
                        SelectedUOM = decimal.Parse(dsUOM.Tables[0].Rows[2]["UOMID"].ToString());
                        decimal rowQty = decimal.Parse(txtUsrQty.Text.ToString());
                        decimal UsrQty = SelectedQty * rowQty;

                        hdnSelectedQty.Value = SelectedQty.ToString();
                        rowQtySpn.Text       = UsrQty.ToString();
                    }

                    ddl.Attributes.Add("onchange", "javascript:GetIndex(this,'" + hdnUOM.ClientID.ToString() + "','" + rowQtySpn.ClientID.ToString() + "','" + txtUsrQty.ClientID.ToString() + "'," + e.Row.RowIndex + "," + Price + ",'" + rowPriceTotal.ClientID.ToString() + "'," + moq + ")");

                    txtUsrQty.Attributes.Add("onblur", "javascript:GetIndexQty(this," + SelectedQty + "," + SelectedUOM + ",'" + rowQtySpn.ClientID.ToString() + "','" + txtUsrQty.ClientID.ToString() + "'," + e.Row.RowIndex + "," + Price + ",'" + rowPriceTotal.ClientID.ToString() + "'," + moq + ")");

                    txtUsrPrice.Attributes.Add("onblur", "javascript:GetChangedPrice(this," + SelectedQty + "," + SelectedUOM + ",'" + rowQtySpn.ClientID.ToString() + "','" + txtUsrQty.ClientID.ToString() + "'," + e.Row.RowIndex + ",'" + rowPriceTotal.ClientID.ToString() + "'," + ProdID + ")");
                    //}
                }
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, this, "Request Template", "Grid1_OnRowDataBound");
            }
            finally { objService.Close(); }
        }