예제 #1
0
        /// <summary>
        /// 获取书商
        /// </summary>
        /// <param name="error"></param>
        /// <returns></returns>
        private DictionaryBookSeller GetDictionaryBookSeller(ref List <string> error)
        {
            List <string> errorList = new List <string>();//错误列表
            //规则判断
            //生成对象
            DictionaryBookSeller bookSeller = new DictionaryBookSeller()
            {
                //书商编号
                Id = currentID,
                //书商名称
                BookSeller = textBox_Name.Text.Trim(),
                //地址
                Location = textBox_Adress.Text.Trim(),
                //联系人
                Contact = textBox_CorPL.Text.Trim(),
                //电话
                CallNumber = textBox_Call.Text.Trim(),
                //邮编
                PostCodes = int.Parse(textBox_Postcodes.Text.Trim()),
                //开户行
                BankName = textBox_BankName.Text.Trim(),
                //备注
                Remark = textBox_Remark.Text.Trim(),
            };

            error = errorList;
            return(bookSeller);
        }
예제 #2
0
        /*
         * /// <summary>
         * /// 增加书商数据操作
         * /// </summary>
         * /// <param name="bookseller">书商字典项</param>
         * /// <returns>返回成功与否</returns>
         * public bool AddDicBookSeller(DictionaryBookSeller bookseller)
         * {
         *  string sqlStr = "INSERT INTO tb_DictionaryBookSeller ( " +
         *  "BookSeller," +
         *  "Location," +
         *  " Contact," +
         *  " `CallNumber`," +
         *  " Postcodes," +
         *  " BankName," +
         *  " Remark " +
         *  ")" +
         *  "VALUES(" +
         *  "@BookSeller," +
         *  "@Location," +
         *  " @Contact," +
         *  " @CallNumber," +
         *  " @Postcodes," +
         *  " @BankName," +
         *  " @Remark " +
         *  ");";
         *  //储存DB
         *  MySqlParameter[] para = new MySqlParameter[]
         *  {
         *      new MySqlParameter("@BookSeller",bookseller.BookSeller),
         *      new MySqlParameter("@Location",bookseller.Location),
         *      new MySqlParameter("@Contact",bookseller.Contact),
         *      new MySqlParameter("@CallNumber",bookseller.CallNumber),
         *      new MySqlParameter("@Postcodes",bookseller.PostCodes),
         *      new MySqlParameter("@BankName",bookseller.BankName),
         *      new MySqlParameter("@Remark",bookseller.Remark),
         *  };
         *  int count = helper.ExecuteNonQuery(sqlStr, para, CommandType.Text);
         *  if (count > 0)
         *  {
         *      return true;
         *  }
         *  else
         *  {
         *      return false;
         *  }
         * }*/
        public bool AddDicBookSeller(DictionaryBookSeller bookseller)
        {
            string sqlStr = "AddBooksellerDictionary";

            //储存DB
            MySqlParameter[] para = new MySqlParameter[]
            {
                new MySqlParameter("@returnValue", MySqlDbType.Int32, 4),
                new MySqlParameter("@name", bookseller.BookSeller),
                new MySqlParameter("@location", bookseller.Location),
                new MySqlParameter("@contact", bookseller.Contact),
                new MySqlParameter("@callNum", bookseller.CallNumber),
                new MySqlParameter("@postcodes", bookseller.PostCodes),
                new MySqlParameter("@bankName", bookseller.BankName),
                new MySqlParameter("@remark", bookseller.Remark),
            };
            para[0].Direction = ParameterDirection.Output; //将第一个变量设为输出变量
            int count  = helper.ExecuteNonQuery(sqlStr, para, CommandType.StoredProcedure);
            int result = (int)para[0].Value;               //获取返回值

            if (result == -1)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #3
0
 private void btn_addCase_Click(object sender, EventArgs e)
 {
     try
     {
         List <string> errorList = new List <string>();//创建一个错误列表
         //获取根据当前页面内容生成的订单(若有错误会被添加到错误列表中)
         var list = new DictionaryBookSeller[] { GetDictionaryBookSeller(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();
 }
예제 #4
0
        /// <summary>
        /// 修改书商字典
        /// </summary>
        /// <param name="bookSeller"></param>
        /// <returns></returns>
        public bool UpdateBookSeller(DictionaryBookSeller bookSeller)
        {
            string sqlStr = "UPDATE tb_DictionaryBookSeller SET " +
                            " BookSeller=@BookSeller, " +
                            " Location=@Location, " +
                            " Contact=@Contact, " +
                            " CallNumber=@CallNumber, " +
                            " Postcodes=@Postcodes, " +
                            " BankName=@BankName, " +
                            " Remark=@Remark " +
                            " where Id=@Id;";

            //储存Datatable
            MySqlParameter[] para = new MySqlParameter[]//存储相应参数的容器
            {
                new MySqlParameter("@BookSeller", bookSeller.BookSeller),
                new MySqlParameter("@Location", bookSeller.Location),
                new MySqlParameter("@Contact", bookSeller.Contact),
                new MySqlParameter("@CallNumber", bookSeller.CallNumber),
                new MySqlParameter("@Postcodes", bookSeller.PostCodes),
                new MySqlParameter("@BankName", bookSeller.BankName),
                new MySqlParameter("@Remark", bookSeller.Remark),
                new MySqlParameter("@Id", bookSeller.Id),
            };
            int count = helper.ExecuteNonQuery(sqlStr, para, CommandType.Text);

            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        public void TestUpdateBookSeller()
        {
            Tools.UserCaseHandle userCaseHandle   = new Tools.UserCaseHandle(@"C:\Users\73473\Desktop\软件工程\用例\Update_DictionaryBookSeller.xls");
            IEnumerable          updateBookSeller = userCaseHandle.GetUserCases();
            List <string>        errorList        = new List <string>();

            foreach (var i in updateBookSeller)
            {
                Assert.AreEqual(false, maintainaceBll.UpdateDicBookSeller((DictionaryBookSeller)i, ref errorList));
            }
            int maxId = -1;

            foreach (DictionaryBookSeller i in maintainaceBll.getAllDicBookSellerArry())
            {
                if (i.Id > maxId)
                {
                    maxId = i.Id;
                }
            }
            DictionaryBookSeller bookSeller = new DictionaryBookSeller()
            {
                Id         = maxId,
                BookSeller = "新华书店",
                Location   = "华电路",
                Contact    = "小黄",
                CallNumber = "1234567890",
                PostCodes  = 12345,
                BankName   = "建设银行",
                Remark     = ""
            };

            Assert.AreEqual(true, maintainaceBll.UpdateDicBookSeller(bookSeller, ref errorList));
        }
예제 #6
0
        public IEnumerable getAllDicBookSellerArry()
        {
            List <DictionaryBookSeller> result = new List <DictionaryBookSeller>();

            try
            {
                DataTable datatable = maintainaceDal.getAllDicBookSeller();
                foreach (DataRow dr in datatable.Rows)
                {
                    DictionaryBookSeller bookSeller = new DictionaryBookSeller()
                    {
                        Id         = (int)dr["编号"],
                        BookSeller = dr["书商名字"].ToString(),
                        Location   = dr["地址"].ToString(),
                        Contact    = dr["联系人"].ToString(),
                        CallNumber = dr["电话"].ToString(),
                        PostCodes  = (int)dr["邮编"],
                        BankName   = dr["开户行"].ToString(),
                        Remark     = dr["备注"].ToString()
                    };
                    result.Add(bookSeller);
                }
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
 private void Addlog_click(object sender, System.EventArgs e)
 {
     try
     {
         List <string> errorList = new List <string>();//创建一个错误列表
         //获取根据当前页面内容生成的订单(若有错误会被添加到错误列表中)
         if (comboBox_Dictionary.SelectedIndex == 0)
         {
             DictionaryBookSeller bookSeller = GetDictionaryBookSeller(ref errorList);
             //判断是否添加订单成功
             if (maintainaceBll.AddDicBookSeller(bookSeller, ref errorList))
             {
                 MessageBox.Show("添加成功");
             }
             else
             {
                 MessageBox.Show("添加失败");
                 foreach (var i in errorList)
                 {
                     MessageBox.Show(i);//逐条显示错误信息
                 }
             }
         }
         else if (comboBox_Dictionary.SelectedIndex == 1)
         {
             DictionaryPublishingHouse publishingHouse = GetDictionaryPublishingHouse(ref errorList);
             //判断是否添加订单成功
             if (maintainaceBll.AddDicPublishingHouse(publishingHouse, ref errorList))
             {
                 MessageBox.Show("添加成功");
             }
             else
             {
                 MessageBox.Show("添加失败");
                 foreach (var i in errorList)
                 {
                     MessageBox.Show(i);//逐条显示错误信息
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     //textWritableChange();
     DataBind();
 }
예제 #8
0
        /// <summary>
        /// 通过名字获取书商信息
        /// </summary>
        /// <param name="bookSeller"></param>
        /// <returns></returns>
        public DataTable getBookSellerByName(DictionaryBookSeller bookSeller)
        {
            string sqlStr = "Select " +
                            " tb_DictionaryBookSeller.Id as 编号," +
                            " tb_DictionaryBookSeller.BookSeller as 书商名字," +
                            " tb_DictionaryBookSeller.Location as 地址," +
                            " tb_DictionaryBookSeller.Contact as 联系人," +
                            " tb_DictionaryBookSeller.CallNumber as 电话," +
                            " tb_DictionaryBookSeller.Postcodes as 邮编," +
                            " tb_DictionaryBookSeller.BankName as 开户行," +
                            " tb_DictionaryBookSeller.Remark as 备注" +
                            " from tb_DictionaryBookSeller" +
                            " Where BookSeller =@BookSeller ;";

            MySqlParameter[] para = new MySqlParameter[]
            {
                new MySqlParameter("@BookSeller", bookSeller.BookSeller),
            };
            DataTable dataTable = helper.ExecuteQuery(sqlStr, para, CommandType.Text);

            return(dataTable);
        }
예제 #9
0
        /// <summary>
        /// 更新书商信息名字查重
        /// </summary>
        /// <param name="dictionaryBookSeller"></param>
        /// <returns></returns>
        public bool UpdateCaseNameCheckBS(DictionaryBookSeller dictionaryBookSeller)
        {
            DataTable result = null;

            try
            {
                result = maintainaceDal.getBookSellerByName(dictionaryBookSeller);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
            if (result.Rows.Count <= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #10
0
        /// <summary>
        /// 新增书商字典用户操作
        /// </summary>
        /// <param name="bookSeller">书商项</param>
        /// <param name="errorMsg">错误集</param>
        /// <returns>是否增添成功</returns>
        public bool AddDicBookSeller(DictionaryBookSeller bookSeller, ref List <string> errorMsg)
        {
            bool result = false;

            try
            {
                if (!DictionaryBookSeller.isNull(bookSeller))
                {
                    if (!DictionaryBookSeller.isNormative(bookSeller, ref errorMsg))
                    {
                        if (this.AddCaseNameCheckBS(bookSeller))
                        {
                            result = maintainaceDal.AddDicBookSeller(bookSeller);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
            return(result);
        }