/// <summary>
        /// 获取当前窗体所表示的退货清单
        /// </summary>
        /// <param name="error">错误列表</param>
        /// <returns>退货清单</returns>
        private InterviewReturnList GetReturnList(ref List <string> error)
        {
            List <string> errorList = new List <string>();//错误列表


            //通过订购人账号获取id
            int ordererId = int.Parse(SubscriberTextBox.Text);

            double price;

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

            //根据页面内容构造清单
            InterviewReturnList list = new InterviewReturnList()
            {
                SubDate           = subDatePicker.Value,
                ISBN              = ISBNtextBox.Text,
                OrdererId         = ordererId,
                BookName          = bookNameTextBox.Text,
                Price             = price,
                PublishingHouseId = int.Parse(PublishingHouseTextBox.Text),
                DocumentType      = documentTypeComboBox.Text,
            };

            error = errorList; //返回错误列表
            return(list);      //返回清单
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 添加记录
 /// </summary>
 private void AddButton_Click(object sender, EventArgs e)
 {
     try
     {
         List <string> errorList = new List <string>();//创建一个错误列表
         //获取根据当前页面内容生成的清单(若有错误会被添加到错误列表中)
         InterviewReturnList list = GetReturnList(ref errorList);
         //判断是否添加清单成功
         if (interviewBll.AddReturnList(list, ref errorList))
         {
             MessageBox.Show("添加成功");
         }
         else
         {
             MessageBox.Show("添加失败");
             foreach (var i in errorList)
             {
                 MessageBox.Show(i);//逐条显示错误信息
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     DataBind();
 }
 private void Btn_addCase_Click(object sender, EventArgs e)
 {
     try
     {
         List <string> errorList = new List <string>();//创建一个错误列表
         //获取根据当前页面内容生成的订单(若有错误会被添加到错误列表中)
         var list = new InterviewReturnList[] { GetReturnList(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();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取全部订单
        /// </summary>
        /// <returns>全部订单</returns>
        public IEnumerable GetAllReturnListArray()
        {
            List <InterviewReturnList> result = new List <InterviewReturnList>();

            try
            {
                DataTable datatable = interviewDal.GetAllReturnList();
                foreach (DataRow dr in datatable.Rows)
                {
                    InterviewReturnList interviewReturnList = new InterviewReturnList()
                    {
                        Id                = (int)dr["清单号"],
                        SubDate           = (DateTime)dr["订单日期"],
                        ISBN              = dr["ISBN号"].ToString(),
                        OrdererId         = (int)dr["订购人ID"],
                        BookName          = dr["书名"].ToString(),
                        Price             = double.Parse(dr["价格"].ToString()),
                        PublishingHouseId = int.Parse(dr["出版社ID"].ToString()),
                        DocumentType      = dr["文献类型"].ToString(),
                    };
                    result.Add(interviewReturnList);
                }
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 增加一条退货清单记录
        /// </summary>
        /// <param name="list">退货清单</param>
        /// <returns>增加成功与否</returns>
        public bool AddReturnList(InterviewReturnList list)
        {
            string sqlStr = "INSERT INTO tb_InterviewReturnList (" +
                            "Id," +
                            "SubDate," +
                            "ISBN," +
                            "OrdererId," +
                            "BookName," +
                            "Price," +
                            "PublishingHouseId," +
                            "DocumentType" +
                            ")" +
                            "VALUES(" +
                            "@id," +
                            "@subDate," +
                            "@iSBN," +
                            "@ordererId," +
                            "@bookName," +
                            "@price," +
                            "@publishingHouseId," +
                            "@documentType" +
                            ")";

            //储存Datatable
            MySqlParameter[] para = new MySqlParameter[]//存储相应参数的容器
            {
                new MySqlParameter("@id", list.Id),
                new MySqlParameter("@subDate", list.SubDate),
                new MySqlParameter("@iSBN", list.ISBN),
                new MySqlParameter("@ordererId", list.OrdererId),
                new MySqlParameter("@bookName", list.BookName),
                new MySqlParameter("@price", list.Price),
                new MySqlParameter("@publishingHouseId", list.PublishingHouseId),
                new MySqlParameter("@documentType", list.DocumentType),
            };
            int count = helper.ExecuteNonQuery(sqlStr, para, CommandType.Text);

            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取当前窗体所表示的退货清单
        /// </summary>
        /// <param name="error">错误列表</param>
        /// <returns>退货清单</returns>
        private InterviewReturnList GetReturnList(ref List <string> error)
        {
            List <string> errorList = new List <string>();//错误列表

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

            //判断订购人账号是否符合要求
            Match matchOrderer = Regex.Match(SubscriberTextBox.Text, @"(^\d{8}$)|(^\d{10}$)|(^\d{12}$)");

            if (!matchOrderer.Success)
            {
                errorList.Add("OrdererNumber Error");
            }

            //通过订购人账号获取id
            int ordererId = utilBll.GetUserIdFormNumber(SubscriberTextBox.Text);

            double price;

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

            //根据页面内容构造清单
            InterviewReturnList list = new InterviewReturnList()
            {
                SubDate           = subDatePicker.Value,
                ISBN              = ISBNtextBox.Text,
                OrdererId         = ordererId,
                BookName          = bookNameTextBox.Text,
                Price             = price,
                PublishingHouseId = publisherId,
                DocumentType      = documentTypeComboBox.Text,
            };

            error = errorList; //返回错误列表
            return(list);      //返回清单
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 增加一条退货清单记录
        /// </summary>
        /// <param name="list">退货清单</param>
        /// <param name="errorMsg">增加成功与否</param>
        /// <returns></returns>
        public bool AddReturnList(InterviewReturnList list, ref List <string> errorMsg)
        {
            bool result = false;

            try
            {
                if (!InterviewReturnList.isNull(list))                       //是否有空项
                {
                    if (InterviewReturnList.isNormative(list, ref errorMsg)) //是否符合规范
                    {
                        result = interviewDal.AddReturnList(list);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
            return(result);
        }
        public void TestAddReturnList()
        {
            Tools.UserCaseHandle userCaseHandle = new Tools.UserCaseHandle(@"C:\Users\96464\Desktop\软件工程\测试用例\Add_AcceptanceList.xls");
            IEnumerable          returnList     = userCaseHandle.GetUserCases();
            List <string>        errorList      = new List <string>();

            foreach (var i in returnList)
            {
                Assert.AreEqual(false, interviewBll.AddAcceptanceList((AcceptanceList)i, ref errorList));
            }
            InterviewReturnList list = new InterviewReturnList()
            {
                Id                = 1,
                ISBN              = "1234567890",
                OrdererId         = 1,
                BookName          = "采访单元测试",
                Price             = 1,
                PublishingHouseId = 1,
                DocumentType      = "专著",
            };

            Assert.AreEqual(true, interviewBll.AddReturnList(list, ref errorList));
        }