/// <summary> /// 一号多书时选择其中一本后触发 /// </summary> public void showBook() { int count = salemonbll.SelectBySaleHeadId(SaleHeadId); if (count == 0) { count = 1; } else { count += 1; } string booknum = Request["bookNum"]; int alreadyBought = salemonbll.getBookNumberSumByBookNum(booknum, saleId); BookBasicBll bookbll = new BookBasicBll(); BookBasicData book = bookbll.SelectById(booknum); string remarks = book.Remarks; if (defaultdiscount == "-1") { if (double.Parse(remarks) < 1) { remarks = (double.Parse(remarks) * 100).ToString(); } } //if (remarks == "" || remarks == null) //{ // remarks = defaultdiscount; //} else { remarks = defaultdiscount; } string ISBN = Request["isbn"]; string bookname = Request["bookname"]; string price = Request["price"]; StringBuilder sb = new StringBuilder(); sb.Append("<tbody>"); sb.Append("<tr class='first'><td>" + count + "</td>"); sb.Append("<td>" + "<input type='text' class='isbn textareaISBN' value='" + ISBN + "' onkeyup='this.value=this.value.replace(/[^\r\n0-9]/g,'');' /></td>"); sb.Append("<td>" + booknum + "</td>"); sb.Append("<td>" + bookname + "</td>"); sb.Append("<td>" + price + "</td>"); sb.Append("<td><input class='count textareaCount' type='number' value='" + defaultCopy.ToString() + "'/></td>"); sb.Append("<td><input class='discount textareaDiscount' value='" + remarks + "' onkeyup='this.value=this.value.replace(/[^\r\n0-9]/g,'');' /></td>"); sb.Append("<td>" + "" + "</td>"); sb.Append("<td>" + alreadyBought + "</td></tr>"); sb.Append("</tbody>"); Response.Write(sb.ToString()); Response.End(); }
//private void excelNo() //{ // BookBasicBll bookBasicBll = new BookBasicBll(); // except.Columns.Add("书号", typeof(string)); // except.Columns.Add("id", typeof(string)); // except.Columns.Add("ISBN", typeof(string)); // except.Columns.Add("书名", typeof(string)); // except.Columns.Add("供应商", typeof(string)); // except.Columns.Add("出版日期", typeof(string)); // except.Columns.Add("单价", typeof(double)); // except.Columns.Add("预收数量", typeof(string)); // except.Columns.Add("进货折扣", typeof(string)); // except.Columns.Add("销售折扣", typeof(string)); // except.Columns.Add("备注", typeof(string)); // DataRowCollection count = addBookId().Rows; // int counts = 0; // foreach (DataRow row in count)//遍历excel数据集 // { // try // { // string isbn = row[2].ToString().Trim(); // string bookName = ToSBC(row[3].ToString().Trim()); // double price = Convert.ToDouble(row[6]); // DataRow[] rows = excelToDt().Select(string.Format("ISBN='{0}' and 书名='{1}' and 单价={2}", isbn, bookName, price)); // if (rows.Length == 1)//判断如果DataRow.Length为0,即该行excel数据不存在于表A中,就插入到dt3 // { // //except.Rows.Add(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10]); // BookBasicData basicData = new BookBasicData(); // basicData.BookNum = row[0].ToString(); // basicData.Isbn = isbn; // basicData.BookName = bookName; // basicData.Publisher = row[4].ToString(); // basicData.Time = row[5].ToString(); // //basicData.PublishTime = Convert.ToDateTime(row[5]); // basicData.Price = Convert.ToDouble(row[6]); // basicData.Catalog = row[7].ToString(); // basicData.Author = row[8].ToString(); // basicData.Remarks = row[9].ToString(); // basicData.Dentification = row[10].ToString(); // Result result = bookBasicBll.Insert(basicData); // if (result == Result.添加失败) // { // Response.Write("导入失败,可能重复导入"); // Response.End(); // } // else // { // counts++; // } // } // else // { // excelToDt().Rows.RemoveAt(); // } // } // catch (Exception ex) // { // Response.Write(ex); // Response.End(); // } // } // int cf = row - counts; // Response.Write("导入成功,共导入数据" + counts + "条数据,共有重复数据" + cf + "条"); // Response.End(); //} private void differentDt() { BookBasicBll bookBasicBll = new BookBasicBll(); int j = bookBasicBll.SelectCount(); //数据库无数据时直接导入excel if (j <= 0) { //except = addBookId(); //except= GetDistinctSelf(addBookId(), "ISBN", "书名", "单价"); excelNo(); } else { //except.Columns.Add("书号", typeof(string)); //except.Columns.Add("id", typeof(string)); //except.Columns.Add("ISBN", typeof(string)); //except.Columns.Add("书名", typeof(string)); //except.Columns.Add("供应商", typeof(string)); //except.Columns.Add("出版日期", typeof(string)); //except.Columns.Add("单价", typeof(double)); //except.Columns.Add("预收数量", typeof(string)); //except.Columns.Add("进货折扣", typeof(string)); //except.Columns.Add("销售折扣", typeof(string)); //except.Columns.Add("备注", typeof(string)); BookBasicData bookId = bookbll.getBookNum(); DataRowCollection count = addBookId().Rows; int counts = 0; DataTable dataTable = bookBasicBll.Select(); bool isNull = false; int rowls = 0; int kz = 0; foreach (DataRow row in count)//遍历excel数据集 { try { string isbn = row[2].ToString().Trim(); string bookName = ToSBC(row[3].ToString().Trim()); string supplier = row[4].ToString().Trim(); string accept = row[8].ToString().Trim(); string sale = row[9].ToString().Trim(); string price = row[6].ToString().Trim(); if (price == "" || isbn == "" || bookName == "") { price = "0"; isNull = true; kz++; continue; } DataRow[] rows = dataTable.Select(string.Format("ISBN='{0}' and bookName='{1}' and supplier='{2}' and price='{3}' and author='{4}' and remarks='{5}'", isbn, bookName, supplier, price, accept, sale)); //DataRow[] rows = dataTable.Select(string.Format("ISBN='{0}' and bookName='{1}' and price={2}", isbn, bookName, Convert.ToDouble(price))); if (rows.Length == 0)//判断如果DataRow.Length为0,即该行excel数据不存在于表A中,就插入到dt3 { //except.Rows.Add(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10]); BookBasicData basicData = new BookBasicData(); basicData.BookNum = row[0].ToString(); basicData.Isbn = isbn; basicData.BookName = bookName; basicData.Publisher = row[4].ToString(); basicData.Time = row[5].ToString(); //basicData.PublishTime = Convert.ToDateTime(row[5]); basicData.Price = Convert.ToDouble(price); basicData.Catalog = row[7].ToString(); basicData.Author = row[8].ToString(); basicData.Remarks = row[9].ToString(); basicData.Dentification = row[10].ToString(); basicData.Remarks1 = row[11].ToString(); basicData.Remarks2 = row[12].ToString(); basicData.Remarks3 = row[13].ToString(); Result result = bookBasicBll.Insert(basicData); if (result == Result.添加失败) { Response.Write("远程服务器未响应"); Response.End(); } else { counts++; } } rowls++; } catch (Exception ex) { Response.Write(ex); Response.End(); } } string s = last; Result reg = bookbll.updateBookNum(s); //更新书号 //bookId.NewBookNum = bookId.NewBookNum.Substring(bookId.NewBookNum.Length - 8); //last = last.ToString().Substring(last.ToString().Length - 8); //if (Convert.ToInt64(bookId.NewBookNum) < Convert.ToInt64(last)) //{ // Result reg = bookbll.updateBookNum(s); //更新书号 //} Session["path"] = null; //清除路径session int cf = row - counts; if (counts == 0) { if (isNull) { Response.Write("导入成功,共导入数据" + counts + "条数据,共有重复数据" + cf + "条,共有错误数据" + kz.ToString()); Response.End(); } else { Response.Write("导入失败,共导入数据" + counts + "条数据,共有重复数据" + cf + "条"); Response.End(); } } else { Response.Write("导入成功,共导入数据" + counts + "条数据,共有重复数据" + cf + "条"); Response.End(); } } }
/// <summary> /// 添加销售 /// </summary> public void addsalemon() { string headState = salemonbll.getsaleHeadState(SaleHeadId, saleId); if (headState == "2") { msg.Messege = "该单据已完成,不能再添加数据!"; Response.Write(ObjectToJson(msg)); Response.End(); } else { int RegionId = user.ReginId.RegionId; DataSet stockbook = stockbll.SelectByBookNum(bookNum, RegionId); allstockNum = 0; for (int h = 0; h < stockbook.Tables[0].Rows.Count; h++) { allstockNum += Convert.ToInt32(stockbook.Tables[0].Rows[h]["stockNum"]); } if (number > allstockNum) { msg.Messege = "库存不足,当前最大库存为:" + allstockNum; Response.Write(ObjectToJson(msg)); Response.End(); } else { BookBasicBll Bookbll = new BookBasicBll(); BookBasicData book = new BookBasicData(); book = Bookbll.SelectById(bookNum); string saleHeadId = SaleHeadId; int count = salemonbll.SelectBySaleHeadId(saleHeadId); if (count == 0) { saleIdmonomerId = 1; salemonbll.updateHeadstate(saleId, SaleHeadId, 1); } else { saleIdmonomerId = count + 1; } double price = Convert.ToInt32(book.Price); double totalPrice = price * number; double realPrice = totalPrice * (disCount / 100); DateTime Time = DateTime.Now.ToLocalTime(); SaleMonomer newSalemon = new SaleMonomer() { AlreadyBought = 0, SaleIdMonomerId = saleIdmonomerId, BookNum = bookNum, ISBN1 = bookISBN, SaleHeadId = saleHeadId, Number = number, UnitPrice = price, TotalPrice = totalPrice, RealPrice = realPrice, RealDiscount = disCount, Datetime = Time, SaleTaskId = saleId }; //for (int j = 0; j < stockbook.Tables[0].Rows.Count; j++) //{ // int stockNum = Convert.ToInt32(stockbook.Tables[0].Rows[j]["stockNum"]); // string goodsId = stockbook.Tables[0].Rows[j]["goodsShelvesId"].ToString(); // if (number <= stockNum) // { // int stockcount = stockNum - number; // stockbll.update(stockcount, goodsId, bookNum); // } // else // { // number = number - stockNum; // stockbll.update(0, goodsId, bookNum); // if (number == 0) // { // break; // } // } //} Result res = salemonbll.addsale(RegionId, newSalemon); if (res == Result.添加成功) { updateSalehead(); msg.DataTable = getData(); msg.DataTable1 = "<tr class='first'> <td></td><td><input type='text' id='ISBN' class='isbn textareaISBN' /> </td><td></td><td></td><td></td><td><input class='count textareaCount' type='number'/></td><td><input class='discount textareaDiscount' onkeyup='this.value=this.value.replace(/[^\r\n0-9]/g,'');' /></td><td></td><td></td></tr>"; msg.AllKinds = allkinds.ToString(); msg.Number = allnumber.ToString(); msg.AlltotalPrice = alltotalprice.ToString(); msg.AllrealPrice = allreadprice.ToString(); msg.Messege = "添加成功"; Response.Write(ObjectToJson(msg)); Response.End(); } else { msg.Messege = "添加失败"; Response.Write(ObjectToJson(msg)); Response.End(); } } } }
/// <summary> /// 只有一条数据时 /// </summary> public void backbook() { int count = salemonbll.SelectBySaleHeadId(SaleHeadId); if (count == 0) { count = 1; } else { count += 1; } BookBasicBll bookbll = new BookBasicBll(); string booknum = bookds.Tables[0].Rows[0]["bookNum"].ToString(); //判断库存 DataSet stockbook = stockbll.SelectByBookNum(booknum, user.ReginId.RegionId); if (stockbook == null) { Response.Write("无库存"); Response.End(); } BookBasicData book = bookbll.SelectById(booknum); string remarks = book.Remarks; if (defaultdiscount == "-1") { if (double.Parse(remarks) < 1) { remarks = (double.Parse(remarks) * 100).ToString(); } } else { remarks = defaultdiscount; } //if (remarks == "" || remarks == null) //{ // remarks = defaultdiscount; //} //else //{ // if (double.Parse(remarks) < 1) // { // remarks = (double.Parse(remarks) * 100).ToString(); // } //} StringBuilder sb = new StringBuilder(); sb.Append("<tbody>"); int alreadyBought; string addbooknum; for (int i = 0; i < bookds.Tables[0].Rows.Count; i++) { addbooknum = bookds.Tables[0].Rows[i]["bookNum"].ToString(); alreadyBought = salemonbll.getBookNumberSumByBookNum(addbooknum, saleId); sb.Append("<tr class='first'><td>" + count + "</td>"); sb.Append("<td>" + "<input type='text' class='isbn textareaISBN' value='" + bookds.Tables[0].Rows[i]["ISBN"].ToString() + "' onkeyup='this.value=this.value.replace(/[^\r\n0-9]/g,'');' /></td>"); sb.Append("<td>" + bookds.Tables[0].Rows[i]["bookNum"].ToString() + "</td>"); sb.Append("<td>" + bookds.Tables[0].Rows[i]["bookName"].ToString() + "</td>"); sb.Append("<td>" + bookds.Tables[0].Rows[i]["price"].ToString() + "</td>"); sb.Append("<td><input class='count textareaCount' type='number' value='" + defaultCopy.ToString() + "'/></td>"); sb.Append("<td><input class='discount textareaDiscount' value='" + remarks + "' onkeyup='this.value=this.value.replace(/[^\r\n0-9]/g,'');' /></td>"); sb.Append("<td>" + "" + "</td>"); sb.Append("<td>" + alreadyBought + "</td></tr>"); } sb.Append("</tbody>"); Response.Write(sb.ToString()); Response.End(); }
public void addsalemon(HttpContext context) { string SaleHeadId = context.Request["saleheadID"]; string saleId = context.Request["saletaskID"]; int number = Convert.ToInt32(context.Request["number"]); string bookNum = context.Request["bookNum"]; SaleTaskBll saletaskbll = new SaleTaskBll(); BookBasicData book = new BookBasicData(); BookBasicBll bookbll = new BookBasicBll(); if (teamtype == "team") { int regionid = saletaskbll.GetregionidBysaleid(saleId); DataSet stockbook = stobll.SelectByBookNum(bookNum, regionid); int allstockNum = 0; for (int h = 0; h < stockbook.Tables[0].Rows.Count; h++) { allstockNum += Convert.ToInt32(stockbook.Tables[0].Rows[h]["stockNum"]); } if (number > allstockNum) { context.Response.Write("库存数量不足,当前最大库存为:" + allstockNum); context.Response.End(); } else { BookBasicBll Bookbll = new BookBasicBll(); book = Bookbll.SelectById(bookNum); string remarks = book.Remarks; string defaultdiscount; string bookISBN = book.Isbn; string saleHeadId = SaleHeadId; SaleTask task = saletaskbll.selectById(saleId); defaultdiscount = task.DefaultDiscount.ToString(); if (defaultdiscount == "-1") { if (double.Parse(remarks) < 1) { remarks = (double.Parse(remarks) * 100).ToString(); } } double disCount = double.Parse(remarks); int count = salemonbll.SelectBySaleHeadId(saleHeadId); int saleIdmonomerId; if (count == 0) { saleIdmonomerId = 1; salemonbll.updateHeadstate(saleId, SaleHeadId, 1); } else { saleIdmonomerId = count + 1; } double price = Convert.ToInt32(book.Price); double totalPrice = price * number; double realPrice = totalPrice * (disCount / 100); DateTime Time = DateTime.Now.ToLocalTime(); SaleMonomer newSalemon = new SaleMonomer() { AlreadyBought = 0, SaleIdMonomerId = saleIdmonomerId, BookNum = bookNum, ISBN1 = bookISBN, SaleHeadId = saleHeadId, Number = number, UnitPrice = price, TotalPrice = totalPrice, RealPrice = realPrice, RealDiscount = disCount, Datetime = Time, SaleTaskId = saleId }; //for (int j = 0; j < stockbook.Tables[0].Rows.Count; j++) //{ // int stockNum = Convert.ToInt32(stockbook.Tables[0].Rows[j]["stockNum"]); // string goodsId = stockbook.Tables[0].Rows[j]["goodsShelvesId"].ToString(); // if (number <= stockNum) // { // int stockcount = stockNum - number; // stobll.update(stockcount, goodsId, bookNum); // } // else // { // number = number - stockNum; // stobll.update(0, goodsId, bookNum); // if (number == 0) // { // break; // } // } //} Result insertres = salemonbll.addsale(regionid, newSalemon); string op = context.Request["op"]; if (insertres == Result.添加成功) { //更新单头 updateSalehead(context); if (op == "change") { context.Response.Write("修改成功"); context.Response.End(); } else { context.Response.Write("添加成功"); context.Response.End(); } } else { if (op == "change") { context.Response.Write("修改失败"); context.Response.End(); } else { context.Response.Write("添加失败"); context.Response.End(); } } } } else { BookBasicData bookData = bookbll.SelectById(bookNum); string remarks = bookData.Remarks; string defaultdiscount; string bookISBN = bookData.Isbn; SaleTask task = saletaskbll.selectById(saleId); defaultdiscount = task.DefaultDiscount.ToString(); if (defaultdiscount == "-1") { if (double.Parse(remarks) < 1) { remarks = (double.Parse(remarks) * 100).ToString(); } } //if (remarks == "" || remarks == null) //{ // remarks = defaultdiscount; //} else { remarks = defaultdiscount; } double disCount = double.Parse(remarks); book = bookbll.SelectById(bookNum); string saleHeadId = SaleHeadId; int saleIdmonomerId; int count = salemonbll.SelectByPerSaleHeadId(saleHeadId); if (count == 0) { saleIdmonomerId = 1; salemonbll.updatePerHeadstate(saleId, SaleHeadId, 1); } else { saleIdmonomerId = count + 1; } double price = Convert.ToDouble(book.Price); double totalPrice = price * number; double realPrice = totalPrice * (disCount / 100); DateTime Time = DateTime.Now.ToLocalTime(); SaleMonomer newSalemon = new SaleMonomer() { AlreadyBought = 0, SaleIdMonomerId = saleIdmonomerId, BookNum = bookNum, ISBN1 = bookISBN, SaleHeadId = saleHeadId, Number = number, UnitPrice = price, TotalPrice = totalPrice, RealPrice = realPrice, RealDiscount = disCount, Datetime = Time, SaleTaskId = saleId }; Result res = salemonbll.perInsert(newSalemon); string op = context.Request["op"]; if (res == Result.添加成功) { //更新单头 updateSalehead(context); if (op == "change") { context.Response.Write("修改成功"); context.Response.End(); } else { context.Response.Write("添加成功"); context.Response.End(); } } else { if (op == "change") { context.Response.Write("修改失败"); context.Response.End(); } else { context.Response.Write("添加失败"); context.Response.End(); } } } }
/// <summary> /// 客户选择图书 /// </summary> /// <returns></returns> public string getIsbn() { string op = Request["op"]; string isbn = Request["isbn"]; double disCount = Convert.ToDouble(Request["disCount"]); int billCount = Convert.ToInt32(Request["billCount"]); if (isbn != null && isbn != "") { BookBasicBll bookBasicBll = new BookBasicBll(); DataSet bookDs = bookBasicBll.SelectByIsbn(isbn); if (bookDs != null && bookDs.Tables[0].Rows.Count > 0) { int count = bookDs.Tables[0].Rows.Count; if (count == 1) { string headId = "", bookNum = ""; if (op == "isbn") { headId = Request["headId"]; bookNum = bookDs.Tables[0].Rows[0]["bookNum"].ToString(); } else if (op == "newRetail") { headId = insertHead(); bookNum = bookDs.Tables[0].Rows[0]["bookNum"].ToString(); } add(bookNum, headId, "one"); } if (op == "choose" || op == "newChoose") { int counts = bookDs.Tables[0].Rows.Count; StringBuilder sb = new StringBuilder(); int i = 0; while (i < counts) { DataRow dr = bookDs.Tables[0].Rows[i]; User user = (User)Session["user"]; string bookNum = dr["bookNum"].ToString(); int stockNum = stockBll.selectStockNum(dr["bookNum"].ToString(), user.ReginId.RegionId); if (stockNum <= 0) { bookDs.Tables[0].Rows.RemoveAt(i); counts--; } else { i++; } } if (counts == 0) { Response.Write("无库存|:"); Response.End(); } else if (counts == 1) { string headId = ""; if (op == "choose") { headId = Request["headId"]; } else if (op == "newChoose") { headId = insertHead(); } add(bookDs.Tables[0].Rows[0]["bookNum"].ToString(), headId, "other"); } else { counts = bookDs.Tables[0].Rows.Count; for (int j = 0; j < counts; j++) { DataRow dr = bookDs.Tables[0].Rows[j]; sb.Append("<tr><td><div class='pretty inline'><input type = 'radio' name='radio' value='" + dr["bookNum"].ToString() + "'><label><i class='mdi mdi-check'></i></label></div></td>"); sb.Append("<td>" + dr["ISBN"].ToString() + "</td>"); sb.Append("<td>" + dr["bookNum"].ToString() + "</td>"); sb.Append("<td>" + dr["bookName"].ToString() + "</td>"); sb.Append("<td>" + dr["price"].ToString() + "</td>"); sb.Append("<td>" + dr["supplier"].ToString() + "</td></tr>"); } Response.Write("|:" + sb.ToString()); Response.End(); } } Response.Write("一号多书"); Response.End(); } else { Response.Write("ISBN不存在"); Response.End(); } } return(null); }