예제 #1
0
        public string InsertSODT(SupplyOrder objSupplyOrder)
        {
            int id = 0;

            using (IDbConnection connection = OpenConnection(dataConnection))
            {
                IDbTransaction trn = connection.BeginTransaction();
                try
                {
                    var supplyorderitemrepo = new SupplyOrderItemRepository();
                    foreach (var item in objSupplyOrder.SupplyOrderItems)
                    {
                        if (item.OrderedQty > 0)
                        {
                            item.SupplyOrderId  = objSupplyOrder.SupplyOrderId;
                            item.OrganizationId = objSupplyOrder.OrganizationId;
                            supplyorderitemrepo.InsertSupplyOrderItem(item, connection, trn);
                        }
                    }
                    InsertLoginHistory(dataConnection, objSupplyOrder.CreatedBy, "Update", "LPO", id.ToString(), "0");
                    trn.Commit();
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    trn.Rollback();
                    throw;
                }
                return(objSupplyOrder.SupplyOrderNo);
            }
        }
예제 #2
0
        public string InsertSupplyOrder(SupplyOrder objSupplyOrder)
        {
            int id = 0;

            using (IDbConnection connection = OpenConnection(dataConnection))
            {
                IDbTransaction trn = connection.BeginTransaction();
                try
                {
                    objSupplyOrder.SupplyOrderNo = DatabaseCommonRepository.GetNewDocNo(connection, objSupplyOrder.OrganizationId, 9, true, trn);
                    string sql = @"insert into SupplyOrder(SupplyOrderNo,SupplyOrderDate,SupplierId,QuotaionNoAndDate,SpecialRemarks,PaymentTerms,
                                   DeliveryTerms,RequiredDate,CreatedBy,CreatedDate,OrganizationId,CurrencyId,NetDiscount,DiscountRemarks,NetAmount) 
                                   Values (@SupplyOrderNo,@SupplyOrderDate,@SupplierId,@QuotaionNoAndDate,@SpecialRemarks,@PaymentTerms,@DeliveryTerms,
                                           @RequiredDate,@CreatedBy,@CreatedDate,@OrganizationId, @CurrencyId,@NetDiscount,@DiscountRemarks,@NetAmount);
                                   SELECT CAST(SCOPE_IDENTITY() as int)";

                    id = connection.Query <int>(sql, objSupplyOrder, trn).Single <int>();

                    var supplyorderitemrepo = new SupplyOrderItemRepository();
                    foreach (var item in objSupplyOrder.SupplyOrderItems)
                    {
                        if (item.OrderedQty > 0)
                        {
                            item.SupplyOrderId  = id;
                            item.OrganizationId = objSupplyOrder.OrganizationId;
                            supplyorderitemrepo.InsertSupplyOrderItem(item, connection, trn);
                        }
                    }
                    InsertLoginHistory(dataConnection, objSupplyOrder.CreatedBy, "Create", "LPO", id.ToString(), "0");
                    trn.Commit();
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    trn.Rollback();
                    throw;
                }
                return(objSupplyOrder.SupplyOrderNo);
            }
        }