예제 #1
0
    protected void GridView_batchitems_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            if (ViewState["BatchCurtbl"] != null)
            {
                DataTable dt       = (DataTable)ViewState["BatchCurtbl"];
                int       rowIndex = Convert.ToInt32(e.RowIndex);
                if (dt.Rows.Count >= 1)
                {
                    TextBox box1   = (TextBox)GridView_batchitems.Rows[rowIndex].Cells[4].FindControl("TextBox1");
                    Label   label1 = (Label)GridView_batchitems.Rows[rowIndex].Cells[4].FindControl("Label6");


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


                    GridView_batchitems.EditIndex  = -1;
                    ViewState["BatchCurtbl"]       = dt;
                    GridView_batchitems.DataSource = dt;
                    GridView_batchitems.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   = "";
                }
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Recipes-GridView_batchitems_RowUpdating");
        }
    }
예제 #2
0
    protected void recipe_batchadditem_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable dsi = con.SelecthostProc(Com_username, "Batch_View_SelectByID", new string[] { "id" }, recipe_batchname.SelectedValue);
            if (dsi.Rows.Count > 0)
            {
                DataTable dt = (DataTable)ViewState["BatchCurtbl"];

                DataRow dr;
                dr = dt.NewRow();

                dr["batchid"]    = Convert.ToInt32(recipe_batchname.SelectedValue);
                dr["batchname"]  = recipe_batchname.SelectedItem.Text;
                dr["batchunit"]  = dsi.Rows[0][4].ToString();
                dr["batchprice"] = dsi.Rows[0][2].ToString();
                dr["batchqty"]   = Convert.ToInt32(recipe_batchqty.Text);
                dr["total"]      = Convert.ToInt32(recipe_batchqty.Text) * Convert.ToDecimal(dsi.Rows[0][2].ToString());

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

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

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

                decimal sum = 0;
                foreach (GridViewRow R in GridView_items.Rows)
                {
                    Label t = (Label)R.Cells[5].FindControl("Label5");
                    sum += 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_batchadditem_Click");
        }
    }
예제 #3
0
    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");
        }
    }
예제 #4
0
 protected void GridView_batchitems_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
 {
     try
     {
         GridView_batchitems.EditIndex = -1;
         DataTable dt = (DataTable)ViewState["BatchCurtbl"];
         GridView_batchitems.DataSource = (DataView)dt.DefaultView;
         GridView_batchitems.DataBind();
     }
     catch (Exception ex)
     {
         con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Recipes-GridView_batchitems_RowCancelingEdit");
     }
 }
예제 #5
0
    protected void GridView_batchitems_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            if (ViewState["BatchCurtbl"] != null)
            {
                DataTable dt           = (DataTable)ViewState["BatchCurtbl"];
                DataRow   drCurrentRow = null;
                int       rowIndex     = Convert.ToInt32(e.RowIndex);
                if (dt.Rows.Count > 1)
                {
                    dt.Rows.Remove(dt.Rows[rowIndex]);
                    drCurrentRow                   = dt.NewRow();
                    ViewState["BatchCurtbl"]       = dt;
                    GridView_batchitems.DataSource = dt;
                    GridView_batchitems.DataBind();

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

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

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

                    recipe_sellprice.Text  = "";
                    recipe_costmargin.Text = "";
                    recipe_target.Text     = "";
                    recipe_variance.Text   = "";
                }
            }
        }
        catch (Exception ex)
        {
            con.ExcutehostProc(Com_username, "Log_Issues", new string[] { "msg", "details" }, ex.Message, "Err-Recipes-GridView_batchitems_RowDeleting");
        }
    }
예제 #6
0
    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");
        }
    }