Ejemplo n.º 1
0
        public async Task <(int responseStatus, string responseMessage)> CreateMaterialIssue(MaterialTransction model, List <TransactionItems> items)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("MaterialTransactionId", typeof(int));
            dt.Columns.Add("ItemId", typeof(int));
            dt.Columns.Add("Quantity", typeof(decimal));
            dt.Columns.Add("UnitPrice", typeof(decimal));
            dt.Columns.Add("Remarks", typeof(string));
            dt.Columns.Add("ItemNumber", typeof(int));

            items.ForEach(item =>
            {
                DataRow dr = dt.NewRow();
                dr["MaterialTransactionId"] = 0;
                dr["ItemId"]     = item.ItemId;
                dr["Quantity"]   = item.Quantity;
                dr["UnitPrice"]  = item.UnitPrice;
                dr["Remarks"]    = item.Remarks;
                dr["ItemNumber"] = item.UniqueItemId;
                dt.Rows.Add(dr);
            });

            SqlParameter[] sqlParams =
            {
                new SqlParameter("@employeeId",      model.EmployeeId),
                new SqlParameter("@transactionDate", model.TransactionDate),
                new SqlParameter("@transactionType", model.TransactionType),
                new SqlParameter("@slipNumber",      model.SlipNumber ?? string.Empty),
                new SqlParameter("@createdBy",       model.CreatedBy),
                new SqlParameter("@transactionItem", dt),
            };
            try
            {
                var response = await SqlHelperExtension.ExecuteNonQuery(_connectionString, "Proc_MaterialIssue",
                                                                        CommandType.StoredProcedure,
                                                                        sqlParams);

                return(1, "Material issue inserted");
            }
            catch (Exception ex)
            {
                return(-1, ex.Message);
            }
        }
Ejemplo n.º 2
0
        public async Task <(int responseStatus, string responseMessage)> InsertIGLProduct(List <IGLProduct> modelEntities)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("MaterialId", typeof(int));
            dt.Columns.Add("ItemNumber", typeof(string));
            dt.Columns.Add("Quantity", typeof(decimal));
            dt.Columns.Add("CreatedBy", typeof(int));

            modelEntities.ForEach(item => {
                DataRow row       = dt.NewRow();
                row["MaterialId"] = item.MaterialId;
                row["ItemNumber"] = item.ItemNumber;
                row["Quantity"]   = item.Quantity;
                row["CreatedBy"]  = item.CreatedBy;

                dt.Rows.Add(row);
            });

            SqlParameter[] sqlParams =
            {
                new SqlParameter("@materialId",    modelEntities.First().MaterialId),
                new SqlParameter("@materialCount", modelEntities.Count()),
                new SqlParameter("@iglProduct",    dt)
                {
                    SqlDbType = SqlDbType.Structured
                },
                new SqlParameter("@poNumber",      modelEntities.First().PoNumber)
            };
            try
            {
                var response = await SqlHelperExtension.ExecuteNonQuery(_connectionString, SqlConstant.ProcInsertIGLProduct, System.Data.CommandType.StoredProcedure, sqlParams);

                return(response >= 1 ? (response, "Inserted") : (0, "Exception"));
            }
            catch (Exception ex)
            {
                return(-1, ex.Message);
            }
        }