//刷新 private void skinButton2_Click(object sender, EventArgs e) { //显示出销售表信息 DataTable dt = SaleBll.SelectSale(); this.dgv_xiangqing.DataSource = dt; }
/// <summary> /// 根据时间和姓名查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void skinButton1_Click(object sender, EventArgs e) { int salemanid = SalemanBll.SelectSalemanByName(this.txt_chaxun.Text); if (salemanid == 0) { MessageBox.Show("您查找的员工销售记录不存在", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.dgv_xiangqing.DataSource = SaleBll.SelectSale(); } else { this.dgv_xiangqing.DataSource = SaleBll.SelectSaleByTime(salemanid, this.dateTimePicker1.Text, this.dateTimePicker2.Text); } }
public IActionResult GetComId(int id) { try { var saleBll = new SaleBll(); var sale = saleBll.ObterPorId(id); return(Json(sale)); //Recurso Encontrado mesmo que estege nulo; } catch (Exception ex) { Console.WriteLine(ex.Message); return(StatusCode(404)); //Recurso não Encontrado } }
public IActionResult Delete(int id) { try { var saleBll = new SaleBll(); saleBll.Delete(id); return(StatusCode(204, new { SaleBll = saleBll })); //Indica que o recurso foi excluído com sucesso } catch (Exception ex) { Console.WriteLine(ex.Message); return(StatusCode(404)); //Recurso não Encontrado } }
public IActionResult Post([FromBody] SaleModelView saleModelView) { try { var saleBll = new SaleBll(); saleBll.Inserir(saleModelView); return(StatusCode(201, new { SaleBll = saleBll })); //Postado com sucesso } catch (Exception ex) { Console.WriteLine(ex.Message); return(StatusCode(422)); //Exceções de negócio } }
public IActionResult Put(int id, [FromBody] SaleModelView saleModelView) { try { var saleBll = new SaleBll(); saleBll.Atualizar(id, saleModelView); return(StatusCode(204, new { SaleBll = saleBll })); //Indica que o recurso foi alterado com sucesso } catch (Exception ex) { Console.WriteLine(ex.Message); return(StatusCode(422)); //Exceções de negócio } }
public IActionResult GetAll() { try { var saleBll = new SaleBll(); var listaDeSale = saleBll.ObterTodos(); return(Json(listaDeSale)); //Recurso Encontrado mesmo que estege nulo } catch (Exception ex) { Console.WriteLine(ex.Message); return(StatusCode(404)); //Recurso não Encontrado } }
protected void Page_Load(object sender, EventArgs e) { Sale saleObj = new Sale(); saleObj.SaleId = Int32.Parse(Request.Form["formSaleId"]); saleObj.GoodsId = Int32.Parse(Request.Form["formGoodsId"]); saleObj.SaleNumber = Request.Form["formSaleNumber"]; saleObj.SalePrice = Double.Parse(Request.Form["formSalePrice"]); saleObj.SaleCount = Int32.Parse(Request.Form["formSaleCount"]); saleObj.SaleUnit = Request.Form["formSaleUnit"]; int year = Int32.Parse(Request.Form["formSaleYear"]); int month = Int32.Parse(Request.Form["formSaleMonth"]); int day = Int32.Parse(Request.Form["formSaleDay"]); int hours = Int32.Parse(Request.Form["formSaleHours"]); int minutes = Int32.Parse(Request.Form["formSaleMinutes"]); int seconds = Int32.Parse(Request.Form["formSaleSecond"]); string dateStr = year.ToString() + "-" + (month < 10 ? "0" + month.ToString() : month.ToString()) + "-" + (day < 10 ? "0" + day.ToString() : day.ToString()) + " " + (hours < 10 ? "0" + hours.ToString() : hours.ToString()) + ":" + (minutes < 10 ? "0" + minutes.ToString() : minutes.ToString()) + ":" + (seconds < 10 ? "0" + seconds.ToString() : seconds.ToString()); saleObj.SaleDate = DateTime.Parse(dateStr); SaleBll sb = new SaleBll(); bool success = true; if (saleObj.SaleId == 0) { DateTime now = DateTime.Now; saleObj.SaleNumber = "SA" + now.Year.ToString() + (now.Month < 10 ? "0" + now.Month.ToString() : now.Month.ToString()) + (now.Day < 10 ? "0" + now.Day.ToString() : now.Day.ToString()) + (now.Hour < 10 ? "0" + now.Hour.ToString() : now.Hour.ToString()) + (now.Minute < 10 ? "0" + now.Minute.ToString() : now.Minute.ToString()) + (now.Second < 10 ? "0" + now.Second.ToString() : now.Second.ToString()); success = sb.InsertSale(saleObj); if (success) { Msg.Text = "添加成功!"; } else { Msg.Text = "添加失败!"; } } else { success = sb.UpdateSale(saleObj); if (success) { Msg.Text = "修改成功!"; } else { Msg.Text = "修改失败!"; } } }
private void SaledetailsForm_Load(object sender, EventArgs e) { //显示出销售表信息 this.dgv_xiangqing.AutoGenerateColumns = false; DataTable dt = SaleBll.SelectSale(); this.dgv_xiangqing.DataSource = dt; //初始最大化 this.WindowState = System.Windows.Forms.FormWindowState.Maximized; //设置为可编辑状态 //dgv_xiangqing.BeginEdit(false); //统计总营业额 this.lbl_yinyee.Text = SalesDailBLL.SelectDail().ToString(); }
protected void Page_Load(object sender, EventArgs e) { int saleId = Request.QueryString["saleId"] != null?Int32.Parse(Request.QueryString["saleId"]) : 0; bool success = true; if (saleId != 0) { SaleBll sb = new SaleBll(); success = sb.DeleteSale(saleId); if (success) { Msg.Text = "删除成功!"; } else { Msg.Text = "删除失败!"; } } }
protected void Page_Load(object sender, EventArgs e) { SaleBll sb = new SaleBll(); List <Sale> saleList = sb.GetAllSale(); int showCount = 15; string url = HttpContext.Current.Request.Url.AbsolutePath; int page = Request.QueryString["page"] == null ? 1 : Int32.Parse(Request.QueryString["page"]); int maxPage = saleList.Count % showCount == 0 ? saleList.Count / showCount : saleList.Count / showCount + 1; string html = ""; if (saleList.Count != 0) { SalePageNum.Text = HtmlHelper.PageNumAdminControl(url, "rightFrame", page, maxPage); int startIndex = showCount * (page - 1); int endIndex = page == maxPage ? saleList.Count - 1 : showCount * page - 1; bool tbg = true; for (int i = startIndex; i <= endIndex; i++) { html += tbg ? "<tr class='tbg1'>" : "<tr class='tbg2'>"; html += "<td>" + saleList[i].SaleNumber + "</td>"; html += "<td>" + saleList[i].GoodsName + "</td>"; html += "<td>" + saleList[i].SortName + "</td>"; html += "<td>" + saleList[i].SalePrice.ToString() + "</td>"; html += "<td>" + saleList[i].SaleCount.ToString() + "</td>"; html += "<td>" + saleList[i].SaleUnit + "</td>"; html += "<td>" + saleList[i].SaleDate.ToString("yyyy-MM-dd HH:mm:ss") + "</td>"; html += "<td><a href='/Transaction/SaleEdit.aspx?saleId=" + saleList[i].SaleId.ToString() + "' target='rightFrame'>编辑</a>"; html += " | <a href='/Transaction/SaleDelete.aspx?saleId=" + saleList[i].SaleId.ToString() + "' target='rightFrame'>删除</a>"; html += "</td>"; html += "</tr>"; tbg = !tbg; } SaleListTable.Text = html; } else { SaleListTable.Text = "<tr class='tbg1'><td colspan='8'>暂无记录</td></tr>"; } }
protected void Page_Load(object sender, EventArgs e) { GoodsBll gb = new GoodsBll(); List <Sort> sortList = gb.GetSort(); List <Goods> goodsList = gb.GetAllGoodsOrderByName(); string html = ""; foreach (Sort tempSort in sortList) { html += "<option value='" + tempSort.SortId.ToString() + "'>" + tempSort.SortName + "</option>"; } FormSortIdSelect.Text = html; html = ""; foreach (Goods tempGoods in goodsList) { html += "<option sortTag='" + tempGoods.SortId.ToString() + "' price='" + tempGoods.Price.ToString("f2") + "' value='" + tempGoods.GoodsId.ToString() + "'>" + tempGoods.GoodsName + "</option>"; } FormGoodsIdSelect.Text = html; int saleId = Request.QueryString["saleId"] == null ? 0 : Int32.Parse(Request.QueryString["saleId"]); SaleIdInput.Text = "<input type='hidden' id='formSaleId' name='formSaleId' value='" + saleId.ToString() + "' />"; frontSaleId = saleId; if (saleId != 0) { SaleBll sb = new SaleBll(); Sale saleObj = sb.GetSingleSale(saleId); SaleNumberInput.Text = "<input type='hidden' id='formSaleNumber' name='formSaleNumber' value='" + saleObj.SaleNumber + "' />"; frontSortId = saleObj.SortId; frontGoodsId = saleObj.GoodsId; frontSalePrice = saleObj.SalePrice; frontSaleCount = saleObj.SaleCount; frontSaleUnit = saleObj.SaleUnit; frontSaleDate = saleObj.SaleDate; } else { SaleNumberInput.Text = "<input type='hidden' id='formSaleNumber' name='formSaleNumber' value='' />"; } }
int stocknum = 0; //库存 /// <summary> /// 确定购买按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_jiezhang_Click(object sender, EventArgs e) { if (this.lv_sales.Items.Count == 0) { MessageBox.Show("当前无添加书本", "温馨提示"); return; } else { //检索是否能否成功销售 int error = 0; for (int i = 0; i < this.lv_sales.Items.Count; i++) { stocknum = int.Parse(this.lv_sales.Items[i].SubItems[6].Text.ToString()); if (!BooksBLL.UpdateBooksStockNum(this.lv_sales.Items[i].SubItems[2].Text.ToString(), stocknum)) { error++; } } if (error > 0) { MessageBox.Show("库存数可能不足", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { //存已买的书本的信息 string info = "单号:" + lbl_danhao.Text + "\r\n"; //将书本信息存入字符变量info for (int i = 0; i < this.lv_sales.Items.Count; i++) { info += "书本名字:" + this.lv_sales.Items[i].SubItems[2].Text + "\r\n书本价格:" + this.lv_sales.Items[i].SubItems[4].Text + "\r\n书本折扣:" + this.lv_sales.Items[i].SubItems[5].Text + "\r\n书本数量:" + this.lv_sales.Items[i].SubItems[6].Text + "\r\n"; } info += "总金额:" + lbl_money.Text + "\r\n"; info += "购物员:" + lbl_yuangong.Text; //创建打印信息 for (int i = 0; i < this.lv_sales.Items.Count; i++) { if (stocknum >= 0) { using (StreamWriter st = new StreamWriter(@"D:\小票.txt", false, Encoding.UTF8)) { if (!TextBoxBll.Intextnull(this.txt_shishou.Text, 2) || TextBoxBll.Intextnull(this.txt_shishou.Text, 1)) { if (this.txt_shishou.Text == "") { MessageBox.Show("请输入实收金额", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (this.txt_shishou.Text != null && double.Parse(this.txt_shishou.Text.ToString()) >= double.Parse(this.lbl_money.Text.ToString())) { this.lbl_zhaoling.Text = (double.Parse(this.txt_shishou.Text.ToString()) - double.Parse(this.lbl_money.Text.ToString())).ToString(); st.Write(info); st.Flush(); messge = true; } else { MessageBox.Show("实收金额小于应付金额", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } } else { MessageBox.Show("请正确输入预收金额", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } } } } //结算成功 if (messge) { //将信息保存至销售表 int Salesmanid = SalemanBll.SelectSalemanByName(this.lbl_yuangong.Text); DateTime time = DateTime.Parse(DateTime.Now.ToString("yyyy年MM月dd日")); SaleBll.InsertSale(this.lbl_danhao.Text, time, sum, Salesmanid); for (int j = 0; j < lv_sales.Items.Count; j++) { //将信息保存至销售详情表 SalesDetail sale = new SalesDetail() { BooksID = BooksBLL.GetBooksIDbyBooksName(this.lv_sales.Items[j].SubItems[2].Text), Quantity = num, SalesID = SaleBll.GetSDIDByTime(this.lbl_danhao.Text), AloneAmount = decimal.Parse(this.lv_sales.Items[j].SubItems[4].Text) * decimal.Parse(this.lv_sales.Items[j].SubItems[5].Text) }; SalesDailBLL.InsertSaleDail(sale); } DataTable dt = VipBll.SetVipByMobile(this.txt_vip.Text); if (isVIP) { if (bijiao == true) //总价大于积分,默认为true { double sum2 = sum / 10; // 1:10积分产生 int sum1 = (int)sum2; //积分取整 if (checkBox1.Checked == true) //若使用积分抵扣 { sum = sum - double.Parse(dt.Rows[0][4].ToString()) * 0.1; //真实价格处理 VipBll.ClearjifenByPhone(this.txt_vip.Text); //积分已抵扣完,现将vip积分清空 } VipBll.UpdatejifenByPhone(this.txt_vip.Text, int.Parse(sum1.ToString())); //正常积分增加 this.jifenshu.Text = sum1.ToString(); //显示结账后的积分 } if (bijiao == false) //总价小于积分抵扣。积分有剩 { double sum2 = sum * 10; //花费的积分 int sum5 = (int)(double.Parse(dt.Rows[0][4].ToString()) - sum2); //抵扣后的积分 if (checkBox1.Checked == true) //若使用积分 { sum = 0; //真实价格处理 VipBll.DecreasejifenByPhone(this.txt_vip.Text, int.Parse(sum2.ToString())); //之前积分减去抵扣积分 } VipBll.UpdatejifenByPhone(this.txt_vip.Text, int.Parse(sum.ToString())); //正常积分增加,不过总价以为0,积分不会增加 this.jifenshu.Text = sum5.ToString(); //显示结账后的积分 } } MessageBox.Show("结算成功,祝您生活愉快", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); //信息初始化 this.lv_sales.Items.Clear(); this.lbl_goods.Text = "0"; liushuihao(); this.lbl_money.Text = "0.0000"; num = 1; this.lbl_zhaoling.Text = "0.0"; this.txt_shishou.Text = ""; this.jifenxianshi.Text = ""; error = 0; sum = 0; sum3 = 0; sum4 = 0; bijiao = true; } } }