コード例 #1
0
 /// <summary>
 /// get product wip info
 /// <summary>
 /// <param name=accname>accname</param>
 /// <param name=productid>productid</param>
 /// <param name=mod>model object of warehouseproductinout</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public modProductWip GetProductWipItem(string accname, string productid, out string emsg)
 {
     try
     {
         dalAccPeriodList dal            = new dalAccPeriodList();
         modAccPeriodList mod            = dal.GetItem(accname, out emsg);
         string           inoutdatewhere = "and a.inout_date >= '" + mod.StartDate + "' and a.inout_date <= '" + mod.EndDate + "' ";
         string           sql            = string.Format("select a.product_id,b.product_name,b.min_qty,b.max_qty,sum(a.size * a.start_qty) start_qty,sum(a.size * a.input_qty) input_qty,sum(a.size * a.output_qty) output_qty "
                                                         + "from warehouse_product_inout a inner join product_list b on a.product_id=b.product_id where a.product_id='{0}' " + inoutdatewhere
                                                         + "group by a.product_id,b.product_name,b.min_qty,b.max_qty", productid);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             if (rdr.Read())
             {
                 modProductWip model = new modProductWip();
                 model.ProductId   = dalUtility.ConvertToString(rdr["product_id"]);
                 model.ProductName = dalUtility.ConvertToString(rdr["product_Name"]);
                 model.StartQty    = dalUtility.ConvertToDecimal(rdr["start_qty"]);
                 model.InputQty    = dalUtility.ConvertToDecimal(rdr["input_qty"]);
                 model.OutputQty   = dalUtility.ConvertToDecimal(rdr["output_qty"]);
                 model.EndQty      = model.StartQty + model.InputQty - model.OutputQty;
                 model.MinQty      = dalUtility.ConvertToDecimal(rdr["min_qty"]);
                 model.MaxQty      = dalUtility.ConvertToDecimal(rdr["max_qty"]);
                 emsg = string.Empty;
                 return(model);
             }
             else
             {
                 emsg = "No data found!";
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }