Exemple #1
0
    protected void itemnameAr_search_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable dt = con.SelecthostProc(Com_username, "Ingredient_SelectBynameAr", new string[] { "nameAr " }, item_nameAr.Text);
            if (dt.Rows.Count > 0)
            {
                NotifyMsg("", "none", "");

                GridView_items.DataSource = dt;
                GridView_items.DataBind();

                item_unit.SelectedIndex = 0;
                item_cat.SelectedIndex  = 0;

                item_name.Text  = "";
                item_price.Text = "";
            }
            else
            {
                NotifyMsg("No Data found", "block", "alert alert-error");
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Item-itemnameAr_search_Click");
        }
    }
    private void BindData()
    {
        try
        {
            DataTable dtbycat = con.SelecthostProc(Com_username, "Ingredient_View_Select", null, null);
            if (dtbycat.Rows.Count > 0)
            {
                DataTable dt = GetTable();
                foreach (DataRow dr_ in dtbycat.Rows)
                {
                    DataRow dr;
                    dr              = dt.NewRow();
                    dr["itemcat"]   = dr_["IngredientCat_NameEn"];
                    dr["itemname"]  = dr_["Ingredient_NameEn"];
                    dr["itemunit"]  = dr_["Unit_NameEn"];
                    dr["itemprice"] = dr_["Price"];

                    dt.Rows.Add(dr);
                }
                GridView_items.DataSource = (DataView)dt.DefaultView;
                GridView_items.DataBind();
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-RepMaterials-BindData");
        }
    }
Exemple #3
0
    protected void GridView_items_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            if (ViewState["Curtbl"] != null)
            {
                DataTable dt           = (DataTable)ViewState["Curtbl"];
                DataRow   drCurrentRow = null;
                int       rowIndex     = Convert.ToInt32(e.RowIndex);
                if (dt.Rows.Count > 1)
                {
                    dt.Rows.Remove(dt.Rows[rowIndex]);
                    drCurrentRow              = dt.NewRow();
                    ViewState["Curtbl"]       = dt;
                    GridView_items.DataSource = dt;
                    GridView_items.DataBind();

                    decimal sum = 0;
                    foreach (GridViewRow R in GridView_items.Rows)
                    {
                        Label t = (Label)R.Cells[5].FindControl("Label5");
                        sum += Convert.ToDecimal(t.Text);
                    }

                    batch_totalcost.Text = sum.ToString();
                }
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-MakeIngredient-GridView_items_RowDeleting");
        }
    }
    protected void GridView_items_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            if (ViewState["Curtbl"] != null)
            {
                DataTable dt = (DataTable)ViewState["Curtbl"];
                //DataRow drCurrentRow = null;
                int rowIndex = Convert.ToInt32(e.RowIndex);
                if (dt.Rows.Count >= 1)
                {
                    TextBox box1   = (TextBox)GridView_items.Rows[rowIndex].Cells[4].FindControl("TextBox1");
                    Label   label1 = (Label)GridView_items.Rows[rowIndex].Cells[4].FindControl("Label6");


                    dt.Rows[rowIndex]["itemqty"] = box1.Text;
                    dt.Rows[rowIndex]["total"]   = Convert.ToInt32(dt.Rows[rowIndex]["itemqty"]) * Convert.ToDecimal(dt.Rows[rowIndex]["itemprice"]);


                    GridView_items.EditIndex  = -1;
                    ViewState["Curtbl"]       = dt;
                    GridView_items.DataSource = dt;
                    GridView_items.DataBind();

                    decimal total = 0;
                    decimal sum   = 0;
                    foreach (GridViewRow R in GridView_items.Rows)
                    {
                        Label t = (Label)R.Cells[5].FindControl("Label5");
                        sum += Convert.ToDecimal(t.Text);
                    }

                    decimal sumbatch = 0;
                    foreach (GridViewRow R in GridView_batchitems.Rows)
                    {
                        Label t = (Label)R.Cells[5].FindControl("Label5");
                        sumbatch += Convert.ToDecimal(t.Text);
                    }

                    total = sum + sumbatch;
                    recipe_totalcost.Text = total.ToString();

                    recipe_sellprice.Text  = "";
                    recipe_costmargin.Text = "";
                    recipe_target.Text     = "";
                    recipe_variance.Text   = "";
                }
            }


            //DataTable dt = (DataTable)ViewState["Curtbl"];
            //GridView_items.DataSource = (DataView)dt.DefaultView;
            //GridView_items.DataBind();
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Recipes-GridView_items_RowUpdating");
        }
    }
Exemple #5
0
    protected void GridView_Batchs_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            ViewState["Curtbl"] = GetTable();
            DataTable ds = new DataTable();
            ds = null;
            GridView_items.DataSource = ds;
            GridView_items.DataBind();

            Label lbId = (Label)GridView_Batchs.Rows[e.RowIndex].FindControl("LblBatchID");
            id       = int.Parse(lbId.Text);
            IsUpdate = true;

            DataTable dtbatch = con.SelecthostProc(Com_username, "Batch_SelectByID", new string[] { "id" }, id);
            if (dtbatch.Rows.Count > 0)
            {
                batch_no.Text            = dtbatch.Rows[0][0].ToString();
                batch_nameAr.Text        = dtbatch.Rows[0][1].ToString();
                batch_name.Text          = dtbatch.Rows[0][2].ToString();
                batch_price.Text         = dtbatch.Rows[0][4].ToString();
                batch_totalcost.Text     = dtbatch.Rows[0][3].ToString();
                batch_unit.SelectedValue = dtbatch.Rows[0][5].ToString();


                DataTable dtbatchingred = con.SelecthostProc(Com_username, "BatchIngred_SelectByID", new string[] { "id" }, id);
                if (dtbatchingred.Rows.Count > 0)
                {
                    DataTable dt = GetTable();

                    foreach (DataRow dr_ in dtbatchingred.Rows)
                    {
                        DataRow dr;
                        dr              = dt.NewRow();
                        dr["itemid"]    = dr_["Ingredient_ID"];
                        dr["itemname"]  = dr_["Ingredient_NameEn"];
                        dr["itemunit"]  = dr_["Unit_NameEn"];
                        dr["itemprice"] = dr_["Price"];
                        dr["itemqty"]   = dr_["Qty"];
                        dr["total"]     = dr_["Total"];

                        dt.Rows.Add(dr);
                        ViewState["Curtbl"] = dt;
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();
                }

                batch_save.Visible   = false;
                batch_update.Visible = true;
                batch_delete.Visible = true;
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-MakeIngredient-GridView_Batchs_RowUpdating");
        }
    }
Exemple #6
0
    protected void Batcosts_query_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable ds = new DataTable();
            ds = null;
            GridView_items.DataSource = ds;
            GridView_items.DataBind();

            if (Batcosts_byname.Checked)
            {
                DataTable dtbycat = con.SelecthostProc(Com_username, "Batch_View_SelectByname", new string[] { "name" }, Batcosts_itemname.Text);
                if (dtbycat.Rows.Count > 0)
                {
                    DataTable dt = GetTable();
                    foreach (DataRow dr_ in dtbycat.Rows)
                    {
                        DataRow dr;
                        dr = dt.NewRow();
                        dr["batchname"]  = dr_["Batch_NameEn"];
                        dr["batchunit"]  = dr_["Unit_NameEn"];
                        dr["batchcost"]  = dr_["Batch_Cost"];
                        dr["batchprice"] = dr_["Price"];

                        dt.Rows.Add(dr);
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();
                }
            }
            else if (Batcosts_all.Checked)
            {
                DataTable dtbycat = con.SelecthostProc(Com_username, "Batch_View_Select", null, null);
                if (dtbycat.Rows.Count > 0)
                {
                    DataTable dt = GetTable();
                    foreach (DataRow dr_ in dtbycat.Rows)
                    {
                        DataRow dr;
                        dr = dt.NewRow();
                        dr["batchname"]  = dr_["Batch_NameEn"];
                        dr["batchunit"]  = dr_["Unit_NameEn"];
                        dr["batchcost"]  = dr_["Batch_Cost"];
                        dr["batchprice"] = dr_["Price"];

                        dt.Rows.Add(dr);
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();
                }
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-RepBatchs-Batcosts_query_Click");
        }
    }
Exemple #7
0
    protected void batchnameAr_search_Click(object sender, EventArgs e)
    {
        try
        {
            ViewState["Curtbl"] = GetTable();
            DataTable ds = new DataTable();
            ds = null;
            GridView_items.DataSource = ds;
            GridView_items.DataBind();

            if (batch_nameAr.Text != "")
            {
                DataTable dtbatch = con.SelecthostProc(Com_username, "Batch_SelectByNameAr", new string[] { "nameAr" }, batch_nameAr.Text);
                if (dtbatch.Rows.Count > 0)
                {
                    batch_no.Text            = dtbatch.Rows[0][0].ToString();
                    batch_nameAr.Text        = dtbatch.Rows[0][1].ToString();
                    batch_name.Text          = dtbatch.Rows[0][2].ToString();
                    batch_price.Text         = dtbatch.Rows[0][4].ToString();
                    batch_totalcost.Text     = dtbatch.Rows[0][3].ToString();
                    batch_unit.SelectedValue = dtbatch.Rows[0][5].ToString();


                    DataTable dtbatchingred = con.SelecthostProc(Com_username, "BatchIngred_SelectByNameAr", new string[] { "nameAr" }, batch_nameAr.Text);
                    if (dtbatchingred.Rows.Count > 0)
                    {
                        DataTable dt = GetTable();

                        foreach (DataRow dr_ in dtbatchingred.Rows)
                        {
                            DataRow dr;
                            dr              = dt.NewRow();
                            dr["itemid"]    = dr_["Ingredient_ID"];
                            dr["itemname"]  = dr_["Ingredient_NameEn"];
                            dr["itemunit"]  = dr_["Unit_NameEn"];
                            dr["itemprice"] = dr_["Price"];
                            dr["itemqty"]   = dr_["Qty"];
                            dr["total"]     = dr_["Total"];

                            dt.Rows.Add(dr);
                            ViewState["Curtbl"] = dt;
                        }
                        GridView_items.DataSource = (DataView)dt.DefaultView;
                        GridView_items.DataBind();
                    }

                    batch_save.Visible   = false;
                    batch_update.Visible = true;
                    batch_delete.Visible = true;
                }
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-MakeIngredient-batchnameAr_search_Click");
        }
    }
Exemple #8
0
 private void BindItemData()
 {
     try
     {
         DataTable dtu = con.SelecthostProc(Com_username, "Ingredient_View_Select", null, null);
         GridView_items.DataSource = dtu;
         GridView_items.DataBind();
     }
     catch (Exception ex)
     {
         con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Item-BindItemData");
     }
 }
    protected void recipe_new_Click(object sender, EventArgs e)
    {
        try
        {
            recipe_save.Visible   = true;
            recipe_update.Visible = false;
            recipe_delete.Visible = false;

            string s = NextRecipeID().ToString();
            recipe_no.Text = s;

            NotifyMsg("", "none", "");

            recipe_cat.SelectedIndex = 0;
            recipe_name.Text         = "";
            recipe_nameAr.Text       = "";

            recipe_ingredcat.SelectedIndex  = 0;
            recipe_ingredname.SelectedIndex = 0;
            recipe_ingredqty.Text           = "";

            recipe_batchname.SelectedIndex = 0;
            recipe_batchqty.Text           = "";

            recipe_totalcost.Text  = "";
            recipe_sellprice.Text  = "";
            recipe_costmargin.Text = "";
            recipe_target.Text     = "";
            recipe_variance.Text   = "";


            ViewState["Curtbl"] = GetTable();
            DataTable ds = new DataTable();
            ds = null;
            GridView_items.DataSource = ds;
            GridView_items.DataBind();

            ViewState["BatchCurtbl"] = BatchGetTable();
            DataTable dsbatch = new DataTable();
            dsbatch = null;
            GridView_batchitems.DataSource = dsbatch;
            GridView_batchitems.DataBind();

            BindRecipeData();
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Recipes-recipe_new_Click");
        }
    }
 protected void GridView_items_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
 {
     try
     {
         GridView_items.EditIndex = -1;
         DataTable dt = (DataTable)ViewState["Curtbl"];
         GridView_items.DataSource = (DataView)dt.DefaultView;
         GridView_items.DataBind();
     }
     catch (Exception ex)
     {
         con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Recipes-GridView_items_RowCancelingEdit");
     }
 }
Exemple #11
0
 protected void GridView_items_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     try
     {
         BindItemData();
         GridView_items.PageIndex = e.NewPageIndex;
         GridView_items.DataBind();
         NotifyMsg("", "none", "");
     }
     catch (Exception ex)
     {
         con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Item-GridView_items_PageIndexChanging");
     }
 }
    protected void recipe_additem_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable dsi = con.SelecthostProc(Com_username, "Ingredient_View_SelectByID", new string[] { "id" }, recipe_ingredname.SelectedValue);
            if (dsi.Rows.Count > 0)
            {
                DataTable dt = (DataTable)ViewState["Curtbl"];

                DataRow dr;
                dr = dt.NewRow();

                dr["itemid"]    = Convert.ToInt32(recipe_ingredname.SelectedValue);
                dr["itemname"]  = recipe_ingredname.SelectedItem.Text;
                dr["itemunit"]  = dsi.Rows[0][6].ToString();
                dr["itemprice"] = dsi.Rows[0][4].ToString();
                dr["itemqty"]   = Convert.ToInt32(recipe_ingredqty.Text);
                dr["total"]     = Convert.ToInt32(recipe_ingredqty.Text) * Convert.ToDecimal(dsi.Rows[0][4].ToString());

                dt.Rows.Add(dr);
                ViewState["Curtbl"] = dt;

                //GridView_items.Columns[0].Visible = true;
                GridView_items.DataSource = (DataView)dt.DefaultView;
                GridView_items.DataBind();
                //GridView_items.Columns[0].Visible = false;

                decimal total = 0;
                decimal sum   = 0;
                foreach (GridViewRow R in GridView_items.Rows)
                {
                    Label t = (Label)R.Cells[5].FindControl("Label5");
                    sum += Convert.ToDecimal(t.Text);
                }

                decimal sumbatch = 0;
                foreach (GridViewRow R in GridView_batchitems.Rows)
                {
                    Label t = (Label)R.Cells[5].FindControl("Label5");
                    sumbatch += Convert.ToDecimal(t.Text);
                }
                total = sum + sumbatch;
                recipe_totalcost.Text = total.ToString();
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Recipes-recipe_additem_Click");
        }
    }
Exemple #13
0
    protected void GridView_items_Sorting(object sender, GridViewSortEventArgs e)
    {
        try
        {
            DataTable dtu = con.SelecthostProc(Com_username, "Ingredient_View_Select", null, null);

            if (dtu != null)
            {
                DataView dataView = new DataView(dtu);
                dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection);

                GridView_items.DataSource = dataView;
                GridView_items.DataBind();
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Item-GridView_items_Sorting");
        }
    }
Exemple #14
0
    protected void batch_new_Click(object sender, EventArgs e)
    {
        try
        {
            batch_save.Visible   = true;
            batch_update.Visible = false;
            batch_delete.Visible = false;

            string s = NextBatchID().ToString();
            batch_no.Text = s;

            NotifyMsg("", "none", "");

            batch_batchcat.SelectedIndex   = 0;
            batch_ingredname.SelectedIndex = 0;
            batch_ingredqty.Text           = "";

            batch_unit.SelectedIndex = 0;
            batch_price.Text         = "";
            batch_totalcost.Text     = "";
            batch_name.Text          = "";
            batch_nameAr.Text        = "";

            ViewState["Curtbl"] = GetTable();
            DataTable ds = new DataTable();
            ds = null;
            GridView_items.DataSource = ds;
            GridView_items.DataBind();

            BindBatchData();
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-MakeIngredient-batch_new_Click");
        }
    }
    protected void Reccosts_query_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable ds = new DataTable();
            ds = null;
            GridView_items.DataSource = ds;
            GridView_items.DataBind();

            if (Reccosts_bycat.Checked)
            {
                DataTable dtbycat = con.SelecthostProc(Com_username, "Recipe_View_SelectByCat", new string[] { "cat" }, Reccosts_cat.SelectedValue);
                if (dtbycat.Rows.Count > 0)
                {
                    DataTable dt = GetTable();
                    foreach (DataRow dr_ in dtbycat.Rows)
                    {
                        DataRow dr;
                        dr              = dt.NewRow();
                        dr["reccat"]    = dr_["RecipeCat_NameEn"];
                        dr["recname"]   = dr_["Recipe_NameEn"];
                        dr["reccost"]   = dr_["Recipe_TotalCost"];
                        dr["recprice"]  = dr_["Recipe_SellPrice"];
                        dr["recmargin"] = dr_["Recipe_CostMargin"];
                        dr["rectarget"] = dr_["Recipe_Target"];
                        dr["recvar"]    = dr_["Recipe_Variance"];

                        dt.Rows.Add(dr);
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();
                }
            }
            else if (Reccosts_byname.Checked)
            {
                DataTable dtbycat = con.SelecthostProc(Com_username, "Recipe_View_SelectByname", new string[] { "name" }, Reccosts_itemname.Text);
                if (dtbycat.Rows.Count > 0)
                {
                    DataTable dt = GetTable();
                    foreach (DataRow dr_ in dtbycat.Rows)
                    {
                        DataRow dr;
                        dr              = dt.NewRow();
                        dr["reccat"]    = dr_["RecipeCat_NameEn"];
                        dr["recname"]   = dr_["Recipe_NameEn"];
                        dr["reccost"]   = dr_["Recipe_TotalCost"];
                        dr["recprice"]  = dr_["Recipe_SellPrice"];
                        dr["recmargin"] = dr_["Recipe_CostMargin"];
                        dr["rectarget"] = dr_["Recipe_Target"];
                        dr["recvar"]    = dr_["Recipe_Variance"];

                        dt.Rows.Add(dr);
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();
                }
            }
            else if (Reccosts_all.Checked)
            {
                DataTable dtbycat = con.SelecthostProc(Com_username, "Recipe_View_Select", null, null);
                if (dtbycat.Rows.Count > 0)
                {
                    DataTable dt = GetTable();
                    foreach (DataRow dr_ in dtbycat.Rows)
                    {
                        DataRow dr;
                        dr              = dt.NewRow();
                        dr["reccat"]    = dr_["RecipeCat_NameEn"];
                        dr["recname"]   = dr_["Recipe_NameEn"];
                        dr["reccost"]   = dr_["Recipe_TotalCost"];
                        dr["recprice"]  = dr_["Recipe_SellPrice"];
                        dr["recmargin"] = dr_["Recipe_CostMargin"];
                        dr["rectarget"] = dr_["Recipe_Target"];
                        dr["recvar"]    = dr_["Recipe_Variance"];

                        dt.Rows.Add(dr);
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();
                }
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-RepRecipes-Reccosts_query_Click");
        }
    }
    protected void GridView_items_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        try
        {
            if (Matcosts_bycat.Checked)
            {
                DataTable dtbycat = con.SelecthostProc(Com_username, "Ingredient_SelectByCat", new string[] { "cat" }, Matcosts_cat.SelectedValue);
                if (dtbycat.Rows.Count > 0)
                {
                    DataTable dt = GetTable();
                    foreach (DataRow dr_ in dtbycat.Rows)
                    {
                        DataRow dr;
                        dr              = dt.NewRow();
                        dr["itemcat"]   = dr_["IngredientCat_NameEn"];
                        dr["itemname"]  = dr_["Ingredient_NameEn"];
                        dr["itemunit"]  = dr_["Unit_NameEn"];
                        dr["itemprice"] = dr_["Price"];

                        dt.Rows.Add(dr);
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();

                    GridView_items.PageIndex = e.NewPageIndex;
                    GridView_items.DataBind();
                }
            }
            else if (Matcosts_byname.Checked)
            {
                DataTable dtbycat = con.SelecthostProc(Com_username, "Ingredient_SelectByname", new string[] { "name" }, Matcosts_itemname.Text);
                if (dtbycat.Rows.Count > 0)
                {
                    DataTable dt = GetTable();
                    foreach (DataRow dr_ in dtbycat.Rows)
                    {
                        DataRow dr;
                        dr              = dt.NewRow();
                        dr["itemcat"]   = dr_["IngredientCat_NameEn"];
                        dr["itemname"]  = dr_["Ingredient_NameEn"];
                        dr["itemunit"]  = dr_["Unit_NameEn"];
                        dr["itemprice"] = dr_["Price"];

                        dt.Rows.Add(dr);
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();

                    GridView_items.PageIndex = e.NewPageIndex;
                    GridView_items.DataBind();
                }
            }
            else if (Matcosts_all.Checked)
            {
                BindData();
                GridView_items.PageIndex = e.NewPageIndex;
                GridView_items.DataBind();
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-RepMaterials-GridView_items_PageIndexChanging");
        }
    }
    protected void GridView_Recipes_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            ViewState["Curtbl"] = GetTable();
            DataTable ds = new DataTable();
            ds = null;
            GridView_items.DataSource = ds;
            GridView_items.DataBind();

            ViewState["BatchCurtbl"] = GetTable();
            DataTable dsbatch = new DataTable();
            dsbatch = null;
            GridView_batchitems.DataSource = dsbatch;
            GridView_batchitems.DataBind();

            Label lbId = (Label)GridView_Recipes.Rows[e.RowIndex].FindControl("LblRecipeID");
            id       = int.Parse(lbId.Text);
            IsUpdate = true;

            DataTable dtrecipe = con.SelecthostProc(Com_username, "Recipe_SelectByID", new string[] { "id" }, id);
            if (dtrecipe.Rows.Count > 0)
            {
                recipe_no.Text           = dtrecipe.Rows[0][0].ToString();
                recipe_cat.SelectedValue = dtrecipe.Rows[0][3].ToString();
                recipe_nameAr.Text       = dtrecipe.Rows[0][1].ToString();
                recipe_name.Text         = dtrecipe.Rows[0][2].ToString();
                recipe_sellprice.Text    = dtrecipe.Rows[0][5].ToString();
                recipe_totalcost.Text    = dtrecipe.Rows[0][4].ToString();
                recipe_costmargin.Text   = dtrecipe.Rows[0][6].ToString();
                recipe_target.Text       = dtrecipe.Rows[0][7].ToString();
                recipe_variance.Text     = dtrecipe.Rows[0][8].ToString();


                DataTable dtrecipeingred = con.SelecthostProc(Com_username, "RecipeIngred_SelectByID", new string[] { "id" }, id);
                if (dtrecipeingred.Rows.Count > 0)
                {
                    DataTable dt = GetTable();

                    foreach (DataRow dr_ in dtrecipeingred.Rows)
                    {
                        DataRow dr;
                        dr              = dt.NewRow();
                        dr["itemid"]    = dr_["Ingredient_ID"];
                        dr["itemname"]  = dr_["Ingredient_NameAr"];
                        dr["itemunit"]  = dr_["Unit_NameAr"];
                        dr["itemprice"] = dr_["Price"];
                        dr["itemqty"]   = dr_["Qty"];
                        dr["total"]     = dr_["ExprPrice"];

                        dt.Rows.Add(dr);
                        ViewState["Curtbl"] = dt;
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();
                }

                DataTable dtrecipebatch = con.SelecthostProc(Com_username, "RecipeBatch_SelectByID", new string[] { "id" }, id);
                if (dtrecipebatch.Rows.Count > 0)
                {
                    DataTable dt = BatchGetTable();

                    foreach (DataRow dr_ in dtrecipebatch.Rows)
                    {
                        DataRow dr;
                        dr               = dt.NewRow();
                        dr["batchid"]    = dr_["Batch_ID"];
                        dr["batchname"]  = dr_["Batch_NameAr"];
                        dr["batchunit"]  = dr_["Unit_NameAr"];
                        dr["batchprice"] = dr_["Price"];
                        dr["batchqty"]   = dr_["Qty"];
                        dr["total"]      = dr_["ExprPrice"];

                        dt.Rows.Add(dr);
                        ViewState["BatchCurtbl"] = dt;
                    }
                    GridView_batchitems.DataSource = (DataView)dt.DefaultView;
                    GridView_batchitems.DataBind();
                }

                recipe_save.Visible   = false;
                recipe_update.Visible = true;
                recipe_delete.Visible = true;
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Recipes-GridView_Recipes_RowUpdating");
        }
    }
Exemple #18
0
    protected void Matcosts_query_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable ds = new DataTable();
            ds = null;
            GridView_items.DataSource = ds;
            GridView_items.DataBind();

            if (Matcosts_bycat.Checked)
            {
                DataTable dtbycat = con.SelecthostProc(Com_username, "Ingredient_SelectByCat", new string[] { "cat" }, Matcosts_cat.SelectedValue);
                if (dtbycat.Rows.Count > 0)
                {
                    DataTable dt = GetTable();
                    foreach (DataRow dr_ in dtbycat.Rows)
                    {
                        DataRow dr;
                        dr              = dt.NewRow();
                        dr["itemcat"]   = dr_["IngredientCat_NameAr"];
                        dr["itemname"]  = dr_["Ingredient_NameAr"];
                        dr["itemunit"]  = dr_["Unit_NameAr"];
                        dr["itemprice"] = dr_["Price"];

                        dt.Rows.Add(dr);
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();
                }
            }
            else if (Matcosts_byname.Checked)
            {
                DataTable dtbycat = con.SelecthostProc(Com_username, "Ingredient_SelectBynameAr", new string[] { "nameAr" }, Matcosts_itemname.Text);
                if (dtbycat.Rows.Count > 0)
                {
                    DataTable dt = GetTable();
                    foreach (DataRow dr_ in dtbycat.Rows)
                    {
                        DataRow dr;
                        dr              = dt.NewRow();
                        dr["itemcat"]   = dr_["IngredientCat_NameAr"];
                        dr["itemname"]  = dr_["Ingredient_NameAr"];
                        dr["itemunit"]  = dr_["Unit_NameAr"];
                        dr["itemprice"] = dr_["Price"];

                        dt.Rows.Add(dr);
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();
                }
            }
            else if (Matcosts_all.Checked)
            {
                DataTable dtbycat = con.SelecthostProc(Com_username, "Ingredient_View_Select", null, null);
                if (dtbycat.Rows.Count > 0)
                {
                    DataTable dt = GetTable();
                    foreach (DataRow dr_ in dtbycat.Rows)
                    {
                        DataRow dr;
                        dr              = dt.NewRow();
                        dr["itemcat"]   = dr_["IngredientCat_NameAr"];
                        dr["itemname"]  = dr_["Ingredient_NameAr"];
                        dr["itemunit"]  = dr_["Unit_NameAr"];
                        dr["itemprice"] = dr_["Price"];

                        dt.Rows.Add(dr);
                    }
                    GridView_items.DataSource = (DataView)dt.DefaultView;
                    GridView_items.DataBind();
                }
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-ar_RepMaterials-Matcosts_query_Click");
        }
    }