Exemple #1
0
        public int InsertStockDetails(ref DailyRecipeTransaction Entity_Recipe, out string strError)
        {
            int iInsert = 0;

            strError = string.Empty;
            try
            {
                //---**StockDetails**---
                SqlParameter pAction          = new SqlParameter(DailyRecipeTransaction._Action, SqlDbType.BigInt);
                SqlParameter pOrderId         = new SqlParameter(DailyRecipeTransaction._OrderId, SqlDbType.BigInt);
                SqlParameter pRecipeId        = new SqlParameter(DailyRecipeTransaction._RecipeId, SqlDbType.BigInt);
                SqlParameter pItemId          = new SqlParameter(DailyRecipeTransaction._ItemId, SqlDbType.BigInt);
                SqlParameter pStockDate       = new SqlParameter(DailyRecipeTransaction._StockDate, SqlDbType.DateTime);
                SqlParameter pStockLocationID = new SqlParameter(DailyRecipeTransaction._StockLocationID, SqlDbType.BigInt);
                SqlParameter pQtyPerUnit      = new SqlParameter(DailyRecipeTransaction._QtyPerUnit, SqlDbType.Decimal);
                SqlParameter pActualRate      = new SqlParameter(DailyRecipeTransaction._ActualRate, SqlDbType.Decimal);

                //---**StockDetails**---
                pAction.Value          = 11;
                pOrderId.Value         = Entity_Recipe.OrderId;
                pRecipeId.Value        = Entity_Recipe.RecipeId;
                pItemId.Value          = Entity_Recipe.ItemId;
                pStockDate.Value       = Entity_Recipe.StockDate;
                pStockLocationID.Value = Entity_Recipe.StockLocationID;
                pQtyPerUnit.Value      = Entity_Recipe.QtyPerUnit;
                pActualRate.Value      = Entity_Recipe.ActualRate;

                SqlParameter[] Param = new SqlParameter[] { pAction, pOrderId, pRecipeId, pItemId, pStockDate, pStockLocationID, pQtyPerUnit, pActualRate };

                Open(CONNECTION_STRING);
                BeginTransaction();

                iInsert = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, DailyRecipeTransaction.SP_DailyRecipeTransaction, Param);

                if (iInsert > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                strError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(iInsert);
        }
Exemple #2
0
    protected void BtnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            int UpdateRow = 0, UpdateRowDtls = 0;

            if (ViewState["EditID"] != null)
            {
                Entity_Recipe.OrderId = Convert.ToInt32(ViewState["EditID"]);
            }
            //Entity_Recipe.OrderDate = Convert.ToDateTime(txtDate.ToString());
            Entity_Recipe.OrderDate      = Convert.ToDateTime(System.DateTime.Now.ToString("dd/MMM/yyyy"));
            Entity_Recipe.TotalOrderCost = Convert.ToDecimal(txtTotalOrderCost.Text);

            Entity_Recipe.UserId    = Convert.ToInt32(Session["UserId"]);
            Entity_Recipe.LoginDate = DateTime.Now;

            UpdateRow = Obj_Recipe.UpdateRecord(ref Entity_Recipe, out StrError);

            if (UpdateRow > 0)
            {
                if (ViewState["CurrentTable"] != null)
                {
                    DataTable dtInsert = new DataTable();
                    dtInsert = (DataTable)ViewState["CurrentTable"];
                    for (int i = 0; i < dtInsert.Rows.Count; i++)
                    {
                        Entity_Recipe.RecipeId = Convert.ToInt32(dtInsert.Rows[i]["RecipeId"].ToString());
                        Entity_Recipe.Qty      = Convert.ToDecimal(dtInsert.Rows[i]["Quantity"].ToString());
                        Entity_Recipe.TotalAmt = Convert.ToDecimal(dtInsert.Rows[i]["TotalAmt"].ToString());

                        UpdateRowDtls = Obj_Recipe.InsertDetailsRecord(ref Entity_Recipe, out StrError);
                    }
                }
                if (UpdateRow > 0 && UpdateRowDtls > 0)
                {
                    obj_Comm.ShowPopUpMsg("Record Updated Successfully", this.Page);
                    MakeControlEmpty();
                    MakeEmptyForm();
                    Entity_Recipe = null;
                    Obj_Recipe    = null;
                }
            }
            else
            {
                obj_Comm.ShowPopUpMsg("Please Enter Details ..!", this.Page);
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }
Exemple #3
0
        public int UpdateRecord(ref DailyRecipeTransaction Entity_Recipe, out string strError)
        {
            int iInsert = 0;

            strError = string.Empty;
            try
            {
                SqlParameter pAction         = new SqlParameter(DailyRecipeTransaction._Action, SqlDbType.BigInt);
                SqlParameter pOrderId        = new SqlParameter(DailyRecipeTransaction._OrderId, SqlDbType.BigInt);
                SqlParameter pOrderNo        = new SqlParameter(DailyRecipeTransaction._OrderNo, SqlDbType.NVarChar);
                SqlParameter pOrderDate      = new SqlParameter(DailyRecipeTransaction._OrderDate, SqlDbType.DateTime);
                SqlParameter pTotalOrderCost = new SqlParameter(DailyRecipeTransaction._TotalOrderCost, SqlDbType.Decimal);

                SqlParameter pUpdatedBy   = new SqlParameter(DailyRecipeTransaction._UserId, SqlDbType.BigInt);
                SqlParameter pUpdatedDate = new SqlParameter(DailyRecipeTransaction._LoginDate, SqlDbType.DateTime);

                pAction.Value         = 2;
                pOrderId.Value        = Entity_Recipe.OrderId;
                pOrderNo.Value        = Entity_Recipe.OrderNo;
                pOrderDate.Value      = Entity_Recipe.OrderDate;
                pTotalOrderCost.Value = Entity_Recipe.TotalOrderCost;

                pUpdatedBy.Value   = Entity_Recipe.UserId;
                pUpdatedDate.Value = Entity_Recipe.LoginDate;

                SqlParameter[] Param = new SqlParameter[] { pAction, pOrderId, pOrderNo, pOrderDate, pTotalOrderCost, pUpdatedBy, pUpdatedDate };

                Open(CONNECTION_STRING);
                BeginTransaction();

                iInsert = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, DailyRecipeTransaction.SP_DailyRecipeTransaction, Param);

                if (iInsert > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                strError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(iInsert);
        }
Exemple #4
0
        public int DeleteRecord(ref DailyRecipeTransaction Entity_Recipe, out string strError)
        {
            int iDelete = 0;

            strError = string.Empty;
            try
            {
                SqlParameter pAction  = new SqlParameter(DailyRecipeTransaction._Action, SqlDbType.BigInt);
                SqlParameter pOrderId = new SqlParameter(DailyRecipeTransaction._OrderId, SqlDbType.BigInt);

                SqlParameter pDeletedBy   = new SqlParameter(DailyRecipeTransaction._UserId, SqlDbType.BigInt);
                SqlParameter pDeletedDate = new SqlParameter(DailyRecipeTransaction._LoginDate, SqlDbType.DateTime);

                pAction.Value  = 3;
                pOrderId.Value = Entity_Recipe.OrderId;

                pDeletedBy.Value   = Entity_Recipe.UserId;
                pDeletedDate.Value = Entity_Recipe.LoginDate;

                SqlParameter[] Param = new SqlParameter[] { pAction, pOrderId, pDeletedBy, pDeletedDate };

                Open(CONNECTION_STRING);
                BeginTransaction();

                iDelete = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, DailyRecipeTransaction.SP_DailyRecipeTransaction, Param);

                if (iDelete > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                strError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(iDelete);
        }
Exemple #5
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        try
        {
            int InsertRow = 0, InsertRowDtls = 0, InserStockDtls = 0;
            if (ChkDetails() == true)
            {
                //Entity_Recipe.OrderDate = Convert.ToDateTime(txtDate.ToString());
                Entity_Recipe.OrderDate      = Convert.ToDateTime(System.DateTime.Now.ToString("dd/MMM/yyyy"));
                Entity_Recipe.TotalOrderCost = Convert.ToDecimal(txtTotalOrderCost.Text);

                Entity_Recipe.UserId    = Convert.ToInt32(Session["UserId"]);
                Entity_Recipe.LoginDate = DateTime.Now;

                InsertRow = Obj_Recipe.InsertRecord(ref Entity_Recipe, out StrError);

                if (InsertRow > 0)
                {
                    if (ViewState["CurrentTable"] != null)
                    {
                        DataTable dtInsert     = new DataTable();
                        DataTable dtInsertItem = new DataTable();
                        dtInsert     = (DataTable)ViewState["CurrentTable"];
                        dtInsertItem = (DataTable)ViewState["ItemDetails"];
                        for (int i = 0; i < dtInsert.Rows.Count; i++)
                        {
                            Entity_Recipe.OrderId  = InsertRow;
                            Entity_Recipe.RecipeId = Convert.ToInt32(dtInsert.Rows[i]["RecipeId"].ToString());
                            Entity_Recipe.Qty      = Convert.ToDecimal(dtInsert.Rows[i]["Quantity"].ToString());
                            Entity_Recipe.TotalAmt = Convert.ToDecimal(dtInsert.Rows[i]["TotalAmt"].ToString());

                            //---**StockDetails**---
                            InsertRowDtls = Obj_Recipe.InsertDetailsRecord(ref Entity_Recipe, out StrError);

                            for (int j = 0; j < dtInsertItem.Rows.Count; j++)
                            {
                                if (Convert.ToInt32(dtInsert.Rows[i]["RecipeId"].ToString()) == Convert.ToInt32(dtInsertItem.Rows[j]["RecipeId"].ToString()))
                                {
                                    Entity_Recipe.OrderId  = InsertRow;
                                    Entity_Recipe.RecipeId = Convert.ToInt32(dtInsertItem.Rows[j]["RecipeId"].ToString());
                                    Entity_Recipe.ItemId   = Convert.ToInt32(GridItemDtls.Rows[j].Cells[1].Text);
                                    //Entity_Recipe.UnitId = DateTime.Now;
                                    Entity_Recipe.StockDate       = DateTime.Now;
                                    Entity_Recipe.StockLocationID = Convert.ToInt32(Session["CafeteriaId"]);
                                    Entity_Recipe.QtyPerUnit      = Convert.ToDecimal(GridItemDtls.Rows[j].Cells[8].Text);
                                    Entity_Recipe.ActualRate      = Convert.ToDecimal(GridItemDtls.Rows[j].Cells[4].Text);

                                    InserStockDtls = Obj_Recipe.InsertStockDetails(ref Entity_Recipe, out StrError);
                                }
                            }
                        }
                    }
                    if (InsertRow > 0 && InsertRowDtls > 0)
                    {
                        obj_Comm.ShowPopUpMsg("Record Saved Successfully", this.Page);
                        MakeControlEmpty();
                        MakeEmptyForm();
                        Entity_Recipe = null;
                        Obj_Recipe    = null;
                    }
                }
            }
            else
            {
                obj_Comm.ShowPopUpMsg("Please Enter Details ..!", this.Page);
            }
        }

        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }