예제 #1
0
 partial void ProductReceiveBalanceForwardDetails_Inserting(ProductReceiveBalanceForwardDetail entity)
 {
     if (entity.ProductReceiveBalanceForward.DocumentDate != null)
     {
         //string receiveType = getPOTransactionType(entity.Product);
         entity.LotNo = getNewLotFromStockOnhand("BFIN", entity.ProductReceiveBalanceForward.DocumentDate, entity.Product, "");
     }
 }
예제 #2
0
        //partial void ProductReceiveBalanceForwardDetails_Updated(ProductReceiveBalanceForwardDetail entity)
        //{
        //    using (SqlConnection connection = new SqlConnection())
        //    {
        //        string connectionStringName = this.DataWorkspace.ApplicationData.Details.Name;
        //        connection.ConnectionString = ConfigurationManager.ConnectionStrings["_IntrinsicData"].ConnectionString;

        //        string procedure = string.Empty;
        //        procedure =  "UPDATE StockOnHands ";
        //        procedure += "    SET QuantityOnHand=@qty+QuantityOnHand";
        //        procedure += "       ,CostPrice=CostPrice + (@costPrice * @qty) ";
        //        procedure += "WHERE StockOnHand_Location=@loc ";
        //        procedure += "    AND StockOnHand_Product=@product";
        //        procedure += "    AND LotNo=@lot";

        //        using (SqlCommand command = new SqlCommand(procedure, connection))
        //        {
        //            command.CommandType = CommandType.Text;
                    
                     
        //            command.Parameters.Add(new SqlParameter("@qty", entity.ReceivedQuantity));
        //            command.Parameters.Add(new SqlParameter("@costPrice", entity.CostPrice));
        //            command.Parameters.Add(new SqlParameter("@loc", entity.Location.Id));
        //            command.Parameters.Add(new SqlParameter("@product", entity.Product.Id));
        //            command.Parameters.Add(new SqlParameter("@lot", entity.LotNo));

        //            connection.Open();
        //            int result = command.ExecuteNonQuery();

        //            if (result == 0)
        //            {
        //                procedure = "INSERT INTO StockOnHands (StockOnHand_Location,StockOnHand_Product,LotNo,QuantityOnHand,CostPrice,SellingPrice,IsAvailableForSale,CreatedBy,Created) ";
        //                procedure += "VALUES(@loc,@product,@lot,@qty,@costPrice*@qty,0,1,@userName,GETDATE())";

        //                command.CommandText = procedure;

        //                command.Parameters.Clear();
        //                command.Parameters.Add(new SqlParameter("@loc", entity.Location.Id));
        //                command.Parameters.Add(new SqlParameter("@product", entity.Product.Id));
        //                command.Parameters.Add(new SqlParameter("@lot", entity.LotNo));
        //                command.Parameters.Add(new SqlParameter("@qty", entity.ReceivedQuantity));
        //                command.Parameters.Add(new SqlParameter("@costPrice", entity.CostPrice));
        //                command.Parameters.Add(new SqlParameter("@userName", entity.CreatedBy));

        //                command.ExecuteNonQuery();
        //            }
        //        }
        //    }

        //    this.Details.DiscardChanges();
        //}

        partial void ProductReceiveBalanceForwardDetails_Inserted(ProductReceiveBalanceForwardDetail entity)
        {
            updateStockOnHand(entity.Location, entity.Product, entity.LotNo, entity.ReceivedQuantity, entity.CostAmount);
        }