private void btnAddSellThing_Click(object sender, EventArgs e) { st = new SellThing() { SellNo = txtSellNo.Text, SellName = txtSellName.Text, SellPrice = Convert.ToDecimal(txtSellPrice.Text), format = Convert.ToString(txtformat.Text), Stock = Convert.ToInt32(txtStock.Text), datains_usr = AdminInfo.Account, datains_date = DateTime.Now }; if (CheckInput(st)) { new SellService().InsertSellThing(st); MessageBox.Show("添加商品成功"); dgvSellthing.DataSource = new SellService().SelectSellThingAll(); string SellId = new CounterHelper().GetNewId("SellId"); txtSellNo.Text = SellId; } else { UIMessageBox.ShowError("信息不完整,请检查!"); return; } }
private void btnCancel_Click(object sender, EventArgs e) { if (dgvSellthing.SelectedRows.Count > 0) { DialogResult dr = MessageBox.Show("你确定要删除该消费记录吗?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (dr == DialogResult.Yes) { string time = dgvRoomSell.SelectedRows[0].Cells["SpendTime"].Value.ToString(); string name = dgvRoomSell.SelectedRows[0].Cells["SpendName"].Value.ToString(); string price = dgvRoomSell.SelectedRows[0].Cells["SpendPrice"].Value.ToString(); SellThing s = SellThingManager.SelectSellThingByNameAndPrice(name, price); decimal num = Convert.ToDecimal(dgvRoomSell.SelectedRows[0].Cells["SpendAmount"].Value.ToString()); string Stock = (s.Stock + num).ToString(); if (SellThingManager.DeleteSellThing(txtRoomNo.Text, time) > 0) { MessageBox.Show("删除成功!", "删除提示"); int n = SellThingManager.UpdateSellThing(Stock, s.SellNo); LoadSpendInfo(txtRoomNo.Text); LoadSellThingInfo(); } } else { return; } } else { MessageBox.Show("请选择要删除的消费记录!", "提示信息"); } }
private void btnCancel_Click(object sender, EventArgs e) { if (dgvRoomSell.SelectedRows.Count > 0) { if (UIMessageDialog.ShowMessageDialog("你确定要删除该消费记录吗?", UILocalize.WarningTitle, true, Style)) { string time = dgvRoomSell.SelectedRows[0].Cells["clSpendTime"].Value.ToString(); string name = dgvRoomSell.SelectedRows[0].Cells["clSpendName"].Value.ToString(); string price = dgvRoomSell.SelectedRows[0].Cells["clSpendPrice"].Value.ToString(); SellThing s = SellThingManager.SelectSellThingByNameAndPrice(name, price); decimal num = Convert.ToDecimal(dgvRoomSell.SelectedRows[0].Cells["clSpendAmount"].Value.ToString()); string Stock = (s.Stock + num).ToString(); if (SellThingManager.DeleteSellThing(txtRoomNo.Text, time) > 0) { int n = SellThingManager.UpdateSellThing(Stock, s.SellNo); UIMessageTip.ShowOk("撤销成功!", 1000); LoadSpendInfo(txtRoomNo.Text); LoadSellThingInfo(); } } else { UIMessageTip.ShowError("操作取消!", 1000); } } else { MessageBox.Show("请选择要删除的消费记录!", "提示信息"); } }
public static int InsertSellThing(SellThing st) { string sql = "insert SellThing (SellNo,SellName,SellPrice,"; sql += "format,Stock) values "; sql += "('{0}','{1}','{2}','{3}','{4}')"; sql = string.Format(sql, st.SellNo, st.SellName, st.SellPrice, st.format, st.Stock); return(DBHelper.ExecuteNonQuery(sql)); }
private void btnAddSellThing_Click(object sender, EventArgs e) { st = new SellThing() { SellNo = txtSellNo.Text, SellName = txtSellName.Text, SellPrice = Convert.ToDecimal(txtSellPrice.Text), format = Convert.ToString(txtformat.Text), Stock = Convert.ToInt32(txtStock.Text), }; SellThingManager.InsertSellThing(st); MessageBox.Show("添加商品成功"); dgvSellthing.DataSource = SellService.SelectSellThingAll(); }
private void dgvRoomSell_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (dgvSellthing.SelectedRows.Count > 0) { txtRoomNo.Text = dgvRoomSell.SelectedRows[0].Cells["RoomNo"].Value.ToString(); txtSellName.Text = dgvRoomSell.SelectedRows[0].Cells["SpendName"].Value.ToString(); nudNum.Value = Convert.ToDecimal(dgvRoomSell.SelectedRows[0].Cells["SpendAmount"].Value.ToString()); txtPrice.Text = dgvRoomSell.SelectedRows[0].Cells["SpendPrice"].Value.ToString(); SellThing s = SellThingManager.SelectSellThingByNameAndPrice(txtSellName.Text, txtPrice.Text); txtSellNo.Text = s.SellNo; } } catch { return; } }
public static string GetRandomSellNo() { string SellNo = ""; Random rand = new Random(); SellNo = rand.NextDouble() + ""; SellNo = "ST" + SellNo.Substring(2, 3); SellThing card = SelectSellInfoBySellNo(SellNo); while (card != null) { SellNo = rand.NextDouble() + ""; SellNo = "ST" + SellNo.Substring(2, 3); card = SelectSellInfoBySellNo(SellNo); } return(SellNo); }
public static SellThing SelectSellInfoBySellNo(string SellNo) { SellThing st = null; string sql = "select * from SellThing where SellNo='" + SellNo + "'"; SqlDataReader dr = DBHelper.ExecuteReader(sql); if (dr.Read()) { st = new SellThing(); st.SellNo = Convert.ToString(dr["SellNo"]); st.SellName = Convert.ToString(dr["SellName"]); st.SellPrice = Convert.ToDecimal(dr["SellPrice"]); st.format = Convert.ToString(dr["format"]); st.Stock = Convert.ToInt32(dr["Stock"]); } dr.Close(); DBHelper.Closecon(); return(st); }
/// <summary> /// 根据商品ID查询 /// </summary> /// <param name="No"></param> /// <returns></returns> public static SellThing SelectSellThingByNo(string No) { SellThing s = new SellThing(); string sql = "select * from Sellthing where SellNo='" + No + "'"; SqlDataReader dr = DBHelper.ExecuteReader(sql); while (dr.Read()) { s = new SellThing(); s.SellNo = dr["SellNo"].ToString(); s.SellName = dr["SellName"].ToString(); s.SellPrice = Convert.ToDecimal(dr["SellPrice"]); s.format = (string)dr["format"]; s.Stock = (int)dr["Stock"]; } dr.Close(); DBHelper.Closecon(); return(s); }
private void btnAdd_Click(object sender, EventArgs e) { if (rs == 1)//判断房间编号是否可消费 { if (CheckInput()) { SellThing st = SellThingManager.SelectSellThingByNo(txtSellNo.Text); Room r = RoomManager.SelectRoomByRoomNo(txtRoomNo.Text); Spend s = new Spend() { RoomNo = txtRoomNo.Text, SpendName = txtSellName.Text, SpendAmount = (int)nudNum.Value, CustoNo = r.CustoNo, SpendPrice = Convert.ToDecimal(txtPrice.Text), SpendMoney = Convert.ToDecimal(txtPrice.Text) * nudNum.Value, SpendTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), MoneyState = "未结算", }; int m = SpendManager.InsertSpendInfo(s); if (m > 0) { MessageBox.Show("添加成功"); string Stock = (st.Stock - nudNum.Value).ToString(); int n = SellThingManager.UpdateSellThing(Stock, st.SellNo); LoadSpendInfo(r.RoomNo); LoadSellThingInfo(); #region 获取添加操作日志所需的信息 Operation o = new Operation(); o.OperationTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd,HH:mm:ss")); o.Operationlog = LoginInfo.WorkerClub + LoginInfo.WorkerPosition + LoginInfo.WorkerName + "于" + DateTime.Now + "帮助" + dgvRoomSell.SelectedRows[0].Cells["CustoNo"].Value.ToString() + "进行了消费商品:" + txtSellName.Text + "操作!"; o.OperationAccount = LoginInfo.WorkerClub + LoginInfo.WorkerPosition + LoginInfo.WorkerName; #endregion OperationManager.InsertOperationLog(o); } else { MessageBox.Show("添加失败"); } } } }
public bool CheckInput(SellThing sellThing) { if (string.IsNullOrWhiteSpace(sellThing.SellNo)) { return(false); } if (string.IsNullOrWhiteSpace(sellThing.SellName)) { return(false); } if (string.IsNullOrWhiteSpace(sellThing.SellPrice + "")) { return(false); } if (string.IsNullOrWhiteSpace(sellThing.Stock + "")) { return(false); } return(true); }
/// <summary> /// 查询所有商品 /// </summary> /// <returns></returns> public static List <SellThing> SelectSellThingAll() { List <SellThing> ls = new List <SellThing>(); string sql = "select * from Sellthing"; MySqlDataReader dr = DBHelper.ExecuteReader(sql); while (dr.Read()) { SellThing s = new SellThing(); s.SellNo = dr["SellNo"].ToString(); s.SellName = dr["SellName"].ToString(); s.SellPrice = Convert.ToDecimal(dr["SellPrice"]); s.format = (string)dr["format"]; s.Stock = Convert.ToInt32(dr["Stock"]); ls.Add(s); } dr.Close(); DBHelper.Closecon(); return(ls); }
/// <summary> /// 根据商品名称查询 /// </summary> /// <param name="Name"></param> /// <returns></returns> public static List <SellThing> SelectSellThingByName(string Name) { List <SellThing> ls = new List <SellThing>(); string sql = "select * from Sellthing where SellName like '%" + Name + "%' or SellNo like '%" + Name + "%' or SellPrice like '%" + Name + "%' or format like '%" + Name + "%'"; SqlDataReader dr = DBHelper.ExecuteReader(sql); while (dr.Read()) { SellThing s = new SellThing(); s.SellNo = dr["SellNo"].ToString(); s.SellName = dr["SellName"].ToString(); s.SellPrice = Convert.ToDecimal(dr["SellPrice"]); s.format = (string)dr["format"]; s.Stock = (int)dr["Stock"]; ls.Add(s); } dr.Close(); DBHelper.Closecon(); return(ls); }
/// <summary> /// 根据商品名称和价格查询商品编号 /// </summary> /// <param name="name"></param> /// <param name="price"></param> /// <returns></returns> public static SellThing SelectSellThingByNameAndPrice(string name, string price) { SellThing s = null; string sql = "select * from SELLTHING where SellName='{0}' and SellPrice='{1}'"; sql = string.Format(sql, name, price); SqlDataReader dr = DBHelper.ExecuteReader(sql); if (dr.Read()) { s = new SellThing(); s.SellNo = dr["SellNo"].ToString(); s.SellName = dr["SellName"].ToString(); s.SellPrice = Convert.ToDecimal(dr["SellPrice"]); s.format = (string)dr["format"]; s.Stock = (int)dr["Stock"]; } dr.Close(); DBHelper.Closecon(); return(s); }
private void btnAdd_Click(object sender, EventArgs e) { if (rs == 1)//判断房间编号是否可消费 { if (CheckInput()) { SellThing st = SellThingManager.SelectSellThingByNo(txtSellNo.Text); Room r = RoomManager.SelectRoomByRoomNo(txtRoomNo.Text); Spend s = new Spend() { RoomNo = txtRoomNo.Text, SpendName = txtSellName.Text, SpendAmount = (int)nudNum.Value, CustoNo = r.CustoNo, SpendPrice = Convert.ToDecimal(txtPrice.Text), SpendMoney = Convert.ToDecimal(txtPrice.Text) * nudNum.Value, SpendTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), MoneyState = "未结算", }; int m = SpendManager.InsertSpendInfo(s); if (m > 0) { MessageBox.Show("添加成功"); string Stock = (st.Stock - nudNum.Value).ToString(); int n = SellThingManager.UpdateSellThing(Stock, st.SellNo); LoadSpendInfo(r.RoomNo); LoadSellThingInfo(); } else { MessageBox.Show("添加失败"); } } } }
public bool InsertSellThing([FromBody] SellThing st) { return(new SellService().InsertSellThing(st)); }
public static int InsertSellThing(SellThing st) { return(SellService.InsertSellThing(st)); }