Ejemplo n.º 1
0
        /// <summary>
        /// 获得数据列表(比DataSet效率高,推荐使用)
        /// </summary>
        public List <VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep> GetListArray_Histroy(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Tb_ExpInv_View.* from Tb_ExpInv_View ");


            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }

            strSql.Append(" order by Tb_ExpInv_View.InvName");

            List <VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep> list = new List <VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep>();

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep model = new VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep();


                        object ojb;
                        ojb = dataReader["InvName"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.InvName = Convert.ToString(ojb);
                        }
                        ojb = dataReader["ExpNum"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.ExpNum = (decimal)ojb;
                        }

                        ojb = dataReader["Id"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Id = (int)ojb;
                        }

                        ojb = dataReader["InvId"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.InvId = (int)ojb;
                        }
                        ojb = dataReader["InvNo"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.InvNo = ojb.ToString();
                        }

                        model.ExpUse    = dataReader["ExpUse"].ToString();
                        model.ExpState  = dataReader["ExpState"].ToString();
                        model.ExpRemark = dataReader["ExpRemark"].ToString();
                        ojb             = dataReader["ReturnTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.ReturnTime = (DateTime)ojb;
                        }



                        model.ProNo     = dataReader["ProNo"].ToString();
                        model.ExpRemark = dataReader["ExpRemark"].ToString();

                        ojb = dataReader["ExpTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.ExpTime = (DateTime)ojb;
                        }

                        ojb = dataReader["LoginName"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.LoginName = ojb.ToString();
                        }

                        ojb = dataReader["ExpInvState"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.ExpInvState = ojb.ToString();
                        }



                        list.Add(model);
                    }
                }
            }


            return(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获得数据列表(比DataSet效率高,推荐使用)
        /// </summary>
        public List <VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep> GetListArray_NoReurnInvs(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Tb_ExpInv_NoReurnInvView.*,Tb_Inventory.InvName as baseInvName,InvNo,Tb_Inventory.Id as baseInvId from Tb_Inventory left join  Tb_ExpInv_NoReurnInvView");
            strSql.Append(" on Tb_Inventory.Id=Tb_ExpInv_NoReurnInvView.InvId");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }

            strSql.Append(" order by Tb_Inventory.InvName");

            List <VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep> list = new List <VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep>();

            System.Collections.Hashtable HsInvS = new System.Collections.Hashtable();
            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep model = new VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep();


                        object ojb;
                        ojb = dataReader["baseInvName"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.InvName = Convert.ToString(ojb);
                        }
                        ojb = dataReader["ExpNum"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.ExpNum = (decimal)ojb;
                        }

                        if (!HsInvS.Contains(model.InvName))
                        {
                            if (HsInvS.Keys.Count > 0)
                            {
                                foreach (string invName in HsInvS.Keys)
                                {
                                    //decimal num = Convert.ToDecimal(HsInvS[invName]);

                                    VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep modelTotal = new VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep();
                                    modelTotal.InvId   = list[list.Count - 1].InvId;
                                    modelTotal.InvName = "小计";
                                    //modelTotal.ExpNum = num;
                                    list.Add(modelTotal);
                                }
                                HsInvS.Clear();
                            }
                            HsInvS.Add(model.InvName, "");
                        }
                        //else
                        //{
                        //    decimal num = 0;
                        //    string key = "";
                        //    foreach(string invName in HsInvS.Keys)
                        //    {
                        //        key = invName;
                        //       num=Convert.ToDecimal(HsInvS[invName]) + model.ExpNum;

                        //    }
                        //    HsInvS[key] = num;
                        //}



                        ojb = dataReader["Id"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Id = (int)ojb;
                        }

                        ojb = dataReader["baseInvId"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.InvId = (int)ojb;
                        }
                        ojb = dataReader["InvNo"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.InvNo = ojb.ToString();
                        }

                        model.ExpUse    = dataReader["ExpUse"].ToString();
                        model.ExpState  = dataReader["ExpState"].ToString();
                        model.ExpRemark = dataReader["ExpRemark"].ToString();
                        ojb             = dataReader["ReturnTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.ReturnTime = (DateTime)ojb;
                        }



                        model.ProNo = dataReader["ProNo"].ToString();

                        ojb = dataReader["ExpTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.ExpTime = (DateTime)ojb;
                        }

                        ojb = dataReader["LoginName"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.LoginName = ojb.ToString();
                        }

                        ojb = dataReader["ExpInvState"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.ExpInvState = ojb.ToString();
                        }



                        list.Add(model);
                    }
                }
            }

            if (list.Count > 0)
            {
                if (HsInvS.Keys.Count > 0)
                {
                    foreach (string invName in HsInvS.Keys)
                    {
                        VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep modelTotal = new VAN_OA.Model.ReportForms.Tb_ExpInvsSumRep();
                        modelTotal.InvId   = list[list.Count - 1].InvId;
                        modelTotal.InvName = "小计";

                        list.Add(modelTotal);
                    }
                    HsInvS.Clear();
                }
            }
            return(list);
        }