/// <summary>
        /// 修改一条采访清单记录
        /// </summary>
        /// <param name="list">采访清单</param>
        /// <returns>修改成功与否</returns>
        public bool UpdateInterviewList(InterviewList list, ref List <string> errorMsg)
        {
            bool result = false;

            try
            {
                if (list.Id == 0)
                {
                    errorMsg.Add("Id Error");
                    return(false);
                }
                if (!InterviewList.isNull(list))                       //是否有空项
                {
                    if (InterviewList.isNormative(list, ref errorMsg)) //是否符合规范
                    {
                        result = interviewDal.UpdateInterviewList(list);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
            return(result);
        }
 /// <summary>
 /// 添加记录
 /// </summary>
 private void AddLog_Click(object sender, EventArgs e)
 {
     try
     {
         List <string> errorList = new List <string>();//创建一个错误列表
         //获取根据当前页面内容生成的清单(若有错误会被添加到错误列表中)
         InterviewList list = GetInterviewList(ref errorList);
         //判断是否添加清单成功
         if (interviewBll.AddInterviewList(list, ref errorList))
         {
             MessageBox.Show("添加成功");
         }
         else
         {
             MessageBox.Show("添加失败");
             foreach (var i in errorList)
             {
                 MessageBox.Show(i);//逐条显示错误信息
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     DataBind();
 }
Exemplo n.º 3
0
        public void TestAddInterviewList()
        {
            Tools.UserCaseHandle userCaseHandle = new Tools.UserCaseHandle(@"C:\Users\Mr.Feng\Desktop\软工\测试用例\Add_InterviewList.xls");
            IEnumerable          interviewList  = userCaseHandle.GetUserCases();
            List <string>        errorList      = new List <string>();

            foreach (var i in interviewList)
            {
                Assert.AreEqual(false, interviewBll.AddInterviewList((InterviewList)i, ref errorList));
            }
            InterviewList list = new InterviewList()
            {
                Id                = 1,
                Author            = "测试师",
                ISBN              = "1234567890",
                PublishingHouseId = 1,
                Price             = 50,
                CurrencyType      = "美元$",
                SubscriptionNum   = 1,
                DocumentType      = "期刊",
                OrderStatus       = "采访",
                BookName          = "单元测试"
            };

            Assert.AreEqual(true, interviewBll.AddInterviewList(list, ref errorList));
        }
        /// <summary>
        /// 获取全部订单
        /// </summary>
        /// <returns>全部订单</returns>
        public IEnumerable GetAllInterviewListArray()
        {
            List <InterviewList> result = new List <InterviewList>();

            try
            {
                DataTable datatable = interviewDal.GetAllInterviewList();
                foreach (DataRow dr in datatable.Rows)
                {
                    InterviewList interviewList = new InterviewList()
                    {
                        Id                = (int)dr["清单号"],
                        ISBN              = dr["ISBN号"].ToString(),
                        Author            = dr["作者"].ToString(),
                        BookName          = dr["书名"].ToString(),
                        Price             = double.Parse(dr["价格"].ToString()),
                        CurrencyType      = dr["货币种类"].ToString(),
                        SubscriptionNum   = (int)dr["征订册数"],
                        PublishingHouseId = int.Parse(dr["出版社"].ToString()),
                        DocumentType      = dr["文献类型"].ToString(),
                        OrderStatus       = dr["订购状态"].ToString(),
                    };
                    result.Add(interviewList);
                }
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
Exemplo n.º 5
0
 private void Btn_addCase_Click(object sender, EventArgs e)
 {
     try
     {
         List <string> errorList = new List <string>();//创建一个错误列表
         //获取根据当前页面内容生成的订单(若有错误会被添加到错误列表中)
         var list = new InterviewList[] { GetInterviewList(ref errorList) };
         if (errorList.Count == 0)
         {
             if (userCaseHandle.AddUserCases(list.ToList()))
             {
                 MessageBox.Show("添加成功");
             }
         }
         else
         {
             MessageBox.Show("添加失败");
             foreach (var i in errorList)
             {
                 MessageBox.Show(i);//逐条显示错误信息
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     DataBind();
 }
        /// <summary>
        /// 增加一条采访清单记录
        /// </summary>
        /// <param name="list">采访清单</param>
        /// <returns>增加成功与否</returns>
        public bool AddInterviewList(InterviewList list)
        {
            string sqlStr = "INSERT INTO tb_InterviewList (" +
                            "Author," +
                            "ISBN," +
                            "OrderStatus," +
                            "BookName," +
                            "Price," +
                            "CurrencyType," +
                            "SubscriptionNum," +
                            "PublishingHouseId," +
                            "DocumentType" +
                            ")" +
                            "VALUES(" +
                            "@author," +
                            "@iSBN," +
                            "@orderStatus," +
                            "@bookName," +
                            "@price," +
                            "@currencyType," +
                            "@subscriptionNum," +
                            "@publishingHouseId," +
                            "@documentType" +
                            ")";

            //储存Datatable
            MySqlParameter[] para = new MySqlParameter[]//存储相应参数的容器
            {
                new MySqlParameter("@author", list.Author),
                new MySqlParameter("@iSBN", list.ISBN),
                new MySqlParameter("@bookName", list.BookName),
                new MySqlParameter("@price", list.Price),
                new MySqlParameter("@currencyType", list.CurrencyType),
                new MySqlParameter("@subscriptionNum", list.SubscriptionNum),
                new MySqlParameter("@publishingHouseId", list.PublishingHouseId),
                new MySqlParameter("@orderStatus", list.OrderStatus),
                new MySqlParameter("@documentType", list.DocumentType),
            };
            int count = helper.ExecuteNonQuery(sqlStr, para, CommandType.Text);

            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        public override async Task <InterviewList> getInterviewListByExbContractId(ExbContractIdRequest request, ServerCallContext context)
        {
            try
            {
                InterviewList interviewList = new InterviewList();
                var           list          = await _service.GetInterviewListByExbContractId(request.ExbContractId);

                var result = Mapper.Map <List <Interview>, List <InterviewStruct> >(list);
                interviewList.Listdata.AddRange(result);
                interviewList.Total = result.Count;
                return(interviewList);
            }
            catch (Exception ex)
            {
                LogHelper.Error(this, ex);
                throw ex;
            }
        }
Exemplo n.º 8
0
        public override async Task <InterviewList> getInterviewList(PaginationRequestSearch request, ServerCallContext context)
        {
            try
            {
                InterviewList interviewList = new InterviewList();
                var           search        = Mapper.Map <SearchStruct, SearchModel>(request.Search);
                var           list          = await _service.GetInterviewList(request.Offset, request.Limit, search);

                var result = Mapper.Map <List <Interview>, List <InterviewStruct> >(list);
                interviewList.Listdata.AddRange(result);
                interviewList.Total = await _service.GetInterviewListCount(search);

                return(interviewList);
            }
            catch (Exception ex)
            {
                LogHelper.Error(this, ex);
                throw ex;
            }
        }
        /// <summary>
        /// 增加一条采访清单记录
        /// </summary>
        /// <param name="list">采访清单</param>
        /// <param name="errorMsg">增加成功与否</param>
        /// <returns></returns>
        public bool AddInterviewList(InterviewList list, ref List <string> errorMsg)
        {
            bool result = false;

            try
            {
                if (!InterviewList.isNull(list))                       //是否有空项
                {
                    if (InterviewList.isNormative(list, ref errorMsg)) //是否符合规范
                    {
                        result = interviewDal.AddInterviewList(list);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
            return(result);
        }
        /// <summary>
        /// 获取当前窗体所表示的清单
        /// </summary>
        /// <param name="error">错误列表</param>
        /// <returns>采访清单</returns>
        private InterviewList GetInterviewList(ref List <string> error)
        {
            List <string> errorList = new List <string>();//错误列表

            //出版社Id
            int publisherId = ((KeyValuePair <int, string>)PublishingHouseComboBox.SelectedItem).Key;

            double price;

            //判断价格是否能被转换为浮点型
            if (!double.TryParse(PriceTextBox.Text, out price))
            {
                errorList.Add("Price Error");
            }

            int subscriptionNum;

            //判断征订册数是否能被转换为整型
            if (!int.TryParse(subscriptionNumTextBox.Text, out subscriptionNum))
            {
                errorList.Add("Price Error");
            }

            //根据页面内容构造清单
            InterviewList list = new InterviewList()
            {
                ISBN              = ISBNTextBox.Text,
                Author            = AuthorTextBox.Text,
                BookName          = BookNameTextBox.Text,
                Price             = price,
                CurrencyType      = currencyTypeComboBox.Text,
                SubscriptionNum   = subscriptionNum,
                PublishingHouseId = publisherId,
                DocumentType      = DocumentTypeComboBox.Text,
                OrderStatus       = OrderStatusComboBox.Text
            };

            error = errorList; //返回错误列表
            return(list);      //返回订单
        }
Exemplo n.º 11
0
        /// <summary>
        /// 修改一条采访清单记录
        /// </summary>
        /// <param name="list">采访清单</param>
        /// <returns>修改成功与否</returns>
        public bool UpdateInterviewList(InterviewList list)
        {
            string sqlStr = "UPDATE tb_InterviewList SET " +
                            "ISBN=@iSBN, " +
                            "Author=@author, " +
                            "BookName=@bookName, " +
                            "Price=@price, " +
                            "CurrencyType=@currencyType, " +
                            "SubscriptionNum=@subscriptionNum, " +
                            "PublishingHouseId=@publishingHouseId, " +
                            "DocumentType=@documentType, " +
                            "OrderStatus=@orderStatus " +
                            "where Id=@id;";

            //储存Datatable
            MySqlParameter[] para = new MySqlParameter[]//存储相应参数的容器
            {
                new MySqlParameter("@author", list.Author),
                new MySqlParameter("@iSBN", list.ISBN),
                new MySqlParameter("@documentType", list.DocumentType),
                new MySqlParameter("@bookName", list.BookName),
                new MySqlParameter("@price", list.Price),
                new MySqlParameter("@currencyType", list.CurrencyType),
                new MySqlParameter("@subscriptionNum", list.SubscriptionNum),
                new MySqlParameter("@publishingHouseId", list.PublishingHouseId),
                new MySqlParameter("@id", list.Id),
                new MySqlParameter("@orderStatus", list.OrderStatus),
            };
            int count = helper.ExecuteNonQuery(sqlStr, para, CommandType.Text);

            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 12
0
        public void TestUpdateInterviewList()
        {
            Tools.UserCaseHandle userCaseHandle = new Tools.UserCaseHandle(@"C:\Users\Mr.Feng\Desktop\软工\测试用例\Update_InterviewList.xls");
            IEnumerable          InterviewList  = userCaseHandle.GetUserCases();
            List <string>        errorList      = new List <string>();

            foreach (var i in InterviewList)
            {
                Assert.AreEqual(false, interviewBll.UpdateInterviewList((InterviewList)i, ref errorList));
            }
            int maxId = -1;

            foreach (AcceptanceList i in interviewBll.GetAllInterviewListArray())
            {
                if (i.Id > maxId)
                {
                    maxId = i.Id;
                }
            }
            if (maxId != -1)
            {
                InterviewList list = new InterviewList()
                {
                    Id                = 1,
                    Author            = "测试师",
                    ISBN              = "1234567890",
                    PublishingHouseId = 1,
                    Price             = 50,
                    CurrencyType      = "美元$",
                    SubscriptionNum   = 1,
                    DocumentType      = "期刊",
                    OrderStatus       = "采访",
                    BookName          = "单元测试"
                };
                Assert.AreEqual(true, interviewBll.UpdateInterviewList(list, ref errorList));
            }
        }
 /// <summary>
 /// 保存记录
 /// </summary>
 private void SaveLog_Click(object sender, EventArgs e)
 {
     try
     {
         List <string> errorList = new List <string>(); //创建一个错误列表
         //获取根据当前页面内容生成的清单(若有错误会被添加到错误列表中)
         string interviewId = InterviewIdTextBox.Text;  //获取清单号
         int    id;
         if (!int.TryParse(interviewId, out id))        //将其转换为数字失败
         {
             MessageBox.Show("清单号错误");
             return;
         }
         InterviewList list = GetInterviewList(ref errorList);
         list.Id = id;//设置清单号
         //判断是否添加清单成功
         if (interviewBll.UpdateInterviewList(list, ref errorList))
         {
             MessageBox.Show("修改成功");
         }
         else
         {
             MessageBox.Show("修改失败");
             foreach (var i in errorList)
             {
                 MessageBox.Show(i);//逐条显示错误信息
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     DataBind();                 //数据绑定
     ChangeControlEnableState(); //改变菜单按钮启用状态
 }