public List <dynamic> AddGrantCodeOrders(GrantCodeMasterDTO grantCodeMasterDTO) { List <dynamic> objDynamic = new List <dynamic>(); var Data = JsonConvert.DeserializeObject <List <GrantCodeMaster> >(grantCodeMasterDTO.GrantCodeMaster); Int64 OrderID = 0, CustID = 0, GrantOrderSerialId = 0; OrderID = Convert.ToInt64(securityHelper.Decrypt(grantCodeMasterDTO.OrderID, false)); CustID = Convert.ToInt64(CustomerID); GrantCodeOrders grantCodeOrders = new GrantCodeOrders(); GrantCodeMaster grantCodeMaster = new GrantCodeMaster(); GrantCodeWiseOrderTotal grantCodeWiseOrderTotal = new GrantCodeWiseOrderTotal(); grantCodeOrders.OrderId = OrderID; grantCodeOrders.CustId = CustID; grantCodeOrders.NoofGrantCodes = Data.Count; AddGrantCodeOrders(grantCodeOrders); grantCodeWiseOrderTotal.GrantOrderId = grantCodeOrders.GrantOrderId; grantCodeWiseOrderTotal.Serial = grantCodeOrders.NoofGrantCodes; GrantOrderSerialId = AddGrantCodeWiseOrderTotal(grantCodeWiseOrderTotal); for (int i = 0; i < Data.Count; i++) { grantCodeMaster = Data[i]; GrantCodeOrderDetails grantCodeOrderDetails = new GrantCodeOrderDetails(); grantCodeOrderDetails.GrantOrderSerialId = GrantOrderSerialId; grantCodeOrderDetails.Serial = i + 1; grantCodeOrderDetails.Value = grantCodeMaster.Data; grantCodeOrderDetails.GrantId = grantCodeMaster.GrantId; AddGrntCodeOrdrDetls(grantCodeOrderDetails); } return(GrantCodeOrderDetails(grantCodeMasterDTO.OrderID)); }
/* * public List<dynamic> GetCustBudgetMastr(Int64 OrderId) * { * List<dynamic> objDynamic = new List<dynamic>(); * DataSet ds = GetCustBudgetData(OrderId); * var myEnumerable = ds.Tables[0].AsEnumerable(); * * List<BudgetCodeMstr> BudgetCodeMstr = * (from item in myEnumerable * select new BudgetCodeMstr * { * BudgetId = item.Field<Int64>("BudgetId "), * BudgetTitle = item.Field<string>("BudgetTitle"), * CustId = item.Field<Int64>("CustId"), * isRequired = item.Field<Boolean>("isRequired"), * FldLength = item.Field<int>("FldLength"), * Serial = item.Field<int>("Serial"), * DependOn = item.Field<Int64>("DependOn") * }).ToList(); * objDynamic.Add(BudgetCodeMstr); * * var Order = ds.Tables[1].AsEnumerable(); * List<OrdrDetail> OrdrDetail = * (from item in Order * select new OrdrDetail * { * ODID = item.Field<Int64>("ODID"), * Serial = item.Field<int>("Serial"), * OrderId = item.Field<Int64>("OrderId"), * ProductId = item.Field<Int64>("ProductId"), * Qty = item.Field<int>("Qty"), * Rate = item.Field<Decimal>("Rate"), * Amount = item.Field<Decimal>("Amount") * * }).ToList(); * objDynamic.Add(OrdrDetail); * * * * * return objDynamic; * } * */ private int AddGrntCodeOrdrDetls(GrantCodeOrderDetails grantCODtls) { int BudgetId = 0; string insertProcedure = "[CreatGrantCodeOrderDetails]"; SqlCommand insertCommand = new SqlCommand(insertProcedure, connection); insertCommand.CommandType = CommandType.StoredProcedure; if (grantCODtls.GrantOrderSerialId != 0) { insertCommand.Parameters.AddWithValue("@GrantOrderSerialId", grantCODtls.GrantOrderSerialId); } else { insertCommand.Parameters.AddWithValue("@GrantOrderSerialId", 0); } if (grantCODtls.GrantId != 0) { insertCommand.Parameters.AddWithValue("@GrantId", grantCODtls.GrantId); } else { insertCommand.Parameters.AddWithValue("@GrantId", 0); } if (!string.IsNullOrEmpty(grantCODtls.Value)) { insertCommand.Parameters.AddWithValue("@Value", grantCODtls.Value); } else { insertCommand.Parameters.AddWithValue("@BudgetTitle", DBNull.Value); } if (grantCODtls.Serial != 0) { insertCommand.Parameters.AddWithValue("@Serial ", grantCODtls.Serial); } else { insertCommand.Parameters.AddWithValue("@Total ", 0); } insertCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int); insertCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output; insertCommand.Parameters.Add("@BudgetIdout", System.Data.SqlDbType.Int); insertCommand.Parameters["@BudgetIdout"].Direction = ParameterDirection.Output; try { int count = 0; connection.Open(); insertCommand.ExecuteNonQuery(); if (insertCommand.Parameters["@ReturnValue"].Value != DBNull.Value) { count = System.Convert.ToInt32(insertCommand.Parameters["@ReturnValue"].Value); } if (insertCommand.Parameters["@BudgetIdout"].Value != DBNull.Value) { BudgetId = System.Convert.ToInt32(insertCommand.Parameters["@BudgetIdout"].Value); } return(BudgetId); } catch (Exception ex) { log.logErrorMessage(""); log.logErrorMessage(ex.StackTrace); return(BudgetId); } finally { connection.Close(); } }