public Party doShipment(StoreRoom storeRoom, Vegetable vegetable, int partyNumber, Party subParty) { List <Party> parties = storerooms[storeRoom.Name].VegatablePartys[vegetable]; foreach (var party in parties) { if (party.Number == partyNumber) { if (party.Weight > subParty.Weight) { party.Weight = subParty.Weight; } else if (party.Weight == subParty.Weight) { parties.Remove(party); } else { throw new Exception("Відвантаження від партії не може перевищувати вагу партії !"); } return(party); } } throw new Exception("НЕ ЗНАЙДЕНО ЖОДНОЇ ПАРТІЇ С ТАКИМ НОМЕРОМ ПАРТІЇ ЗА ОВОЧЕМ "); }
//按键事件 private void txt_Prot_Name_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter) { common.Prot_name = txt_Prot_Name.Text; common.Prot_EnterAndOut = true; Frm_StoreQuery fs = new Frm_StoreQuery(); fs.ShowDialog(); StoreRoom s = common.s; txt_Prot_Bigunit.Text = s.Prot_Bigunit; txt_Prot_Name.Text = s.Prot_name; txt_Prot_Rate.Text = s.Prot_rate.ToString(); txt_Prot_Retailprice.Text = s.Prot_retailprice.ToString(); txt_Prot_Smallunit.Text = s.Prot_smallunit; txt_Prot_Tradeprice.Text = s.Prot_tradeprice.ToString(); cbb_Cards_Name.Text = s.Cards_name; cbb_Priv_Name.Text = s.Priv_name; dtp_Prot_Date.Value = s.Prot_date; lb_Prot_id.Text = s.Prot_id.ToString(); txt_Enter_Num.Focus(); } } catch (Exception) { MessageBox.Show("请选择一项"); } }
public ResultModel Update(StoreRoomModel obj) { ResultModel oOutput = new ResultModel(); try { StoreRoom oStoreRoom = dbSet.Where(m => m.ID == obj.ID).FirstOrDefault(); if (oStoreRoom == null) { oOutput.Status = 0; oOutput.Msg = "Record not exist"; } else { // Removing Already Added Mapper.Map(obj, oStoreRoom); oDB.SaveChanges(); oOutput.Data = Mapper.Map <StoreRoom>(oStoreRoom); } } catch (Exception ex) { oOutput.Status = 0; oOutput.Msg = "Data access error"; Services.Utitilty.Error(ex); } return(oOutput); }
public StoreRoom findStoreRoomByName(string name) { StoreRoom store = storerooms[name]; if (store == null) { return(store); } throw new NullReferenceException(); }
public Party deleteParty(StoreRoom storeRoom, Vegetable vegetable, int partyNumber) { List <Party> parties = storerooms[storeRoom.Name].VegatablePartys[vegetable]; foreach (var party in parties) { if (party.Number == partyNumber) { parties.Remove(party); return(party); } } throw new Exception("НЕ ЗНАЙДЕНО ЖОДНОЇ ПАРТІЇ С ТАКИМ НОМЕРОМ ПАРТІЇ ЗА ОВОЧЕМ "); }
//添加到集合按键事件 private void txt_Enter_Num_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { try { if (Convert.ToInt32(txt_Enter_Num.Text) <= 0) { MessageBox.Show("销售退货不能为负值和0"); txt_Enter_Num.SelectAll(); return; } bool b = true; foreach (StoreRoom var in ls) { if (var.Prot_id.ToString() == lb_Prot_id.Text) { var.In_Out_StoreRoom += Convert.ToInt32(txt_Enter_Num.Text); sum += Convert.ToInt32(txt_Enter_Num.Text); money += Convert.ToInt32(txt_Enter_Num.Text) * var.Prot_tradeprice; b = false; break; } } StoreRoom s = common.s; if (b) { s.In_Out_StoreRoom = Convert.ToInt32(txt_Enter_Num.Text); num++; sum += s.In_Out_StoreRoom; money += s.In_Out_StoreRoom * s.Prot_tradeprice; ls.Add(s); } common.s = null; dgv_Store.DataSource = null; dgv_Store.DataSource = ls; Clear(); txt_Prot_Name.Focus(); lb_money.Text = money.ToString(); lb_num.Text = num.ToString(); lb_sum.Text = sum.ToString(); } catch (Exception) { MessageBox.Show("请输入正确的数字格式"); txt_Enter_Num.SelectAll(); } } }
/// <summary> /// 使用商品名称查询库存信息 /// </summary> /// <param name="Prot_Name">商品名称</param> /// <returns></returns> public List <StoreRoom> GetStoreRoomByProt_Name(string Prot_Name) { List <StoreRoom> ls = new List <StoreRoom>(); SqlConnection con = new SqlConnection(conStr); try { con.Open(); string sql = string.Format("select productInfo.*,Cards.Cardsname,providers.Privname,storeRoom.storelastNum,storeRoom.storesum,storeRoom.storeid from productInfo,Cards,providers,storeRoom where productInfo.ProtCard=Cards.Cardsid and productInfo.ProtproviderId=providers.Privid and productInfo.Protid=storeRoom.Protid and productInfo.Protname like '%{0}%'", Prot_Name); SqlCommand com = new SqlCommand(sql, con); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { StoreRoom sr = new StoreRoom(); sr.Prot_id = Convert.ToInt32(dr["Protid"]); sr.Prot_name = dr["Protname"].ToString(); sr.Prot_retailprice = Convert.ToSingle(dr["Protretailprice"]); sr.Prot_tradeprice = Convert.ToSingle(dr["Prottradeprice"]); sr.Prot_Bigunit = dr["ProtBigunit"].ToString(); sr.Prot_smallunit = dr["Protsmallunit"].ToString(); sr.Prot_rate = Convert.ToInt32(dr["ProtRate"]); CardsInfo cardsInfo = new CardsInfo(); cardsInfo.CardsId = Convert.ToInt32(dr["ProtCard"]); Providers providers = new Providers(); providers.Priv_id = Convert.ToInt32(dr["ProtproviderId"]); sr.Prot_date = Convert.ToDateTime(dr["Protdate"]); sr.Cards_name = dr["Cardsname"].ToString(); sr.Priv_name = dr["Privname"].ToString(); sr.Store_id = Convert.ToInt32(dr["storeid"]); sr.Store_sum = Convert.ToInt32(dr["storesum"]); sr.Store_lastNum = Convert.ToInt32(dr["storelastNum"]); ls.Add(sr); } dr.Close(); } catch (Exception) { MessageBox.Show("系统出现异常,请您稍后再试!"); } finally { con.Close(); } return(ls); }
public Party editParty(StoreRoom storeRoom, int partyNumber, Party partyEditted) { var vegetable = partyEditted.Vegetable; List <Party> parties = storerooms[storeRoom.Name].VegatablePartys[vegetable]; foreach (var party in parties) { if (party.Number == partyNumber) { party.Price = partyEditted.Price; party.ExpirationTime = partyEditted.ExpirationTime; party.Weight = partyEditted.Weight; party.WeightUnit = partyEditted.WeightUnit; return(party); } } throw new Exception("НЕ ЗНАЙДЕНО ЖОДНОЇ ПАРТІЇ С ТАКИМ НОМЕРОМ ПАРТІЇ ЗА ОВОЧЕМ "); }
public ResultModel Insert(StoreRoomModel obj) { ResultModel oOutput = new ResultModel(); try { StoreRoom oStoreRoom = Mapper.Map <StoreRoom>(obj); dbSet.Add(oStoreRoom); oDB.SaveChanges(); oOutput.Data = Mapper.Map <StoreRoomModel>(oStoreRoom); } catch (Exception ex) { oOutput.Status = 0; oOutput.Msg = "Data access error"; Services.Utitilty.Error(ex); } return(oOutput); }
//销售数量按键事件 private void txt_Out_Num_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { try { StoreRoom s = common.s; if (Convert.ToInt32(txt_Out_Num.Text) > s.Store_sum) { MessageBox.Show("库存不够,请进货,或减少销售"); txt_Out_Num.SelectAll(); return; } if (Convert.ToInt32(txt_Out_Num.Text) <= 0) { MessageBox.Show("销售退货不能为负值和0"); txt_Out_Num.SelectAll(); return; } else { bool b = true; foreach (StoreRoom var in ls) { if (var.Prot_id.ToString() == lb_Prot_id.Text) { if (var.In_Out_StoreRoom + Convert.ToInt32(txt_Out_Num.Text) > var.Store_sum) { MessageBox.Show("库存不够,请进货,或减少销售"); txt_Out_Num.SelectAll(); return; } var.In_Out_StoreRoom += Convert.ToInt32(txt_Out_Num.Text); sum += Convert.ToInt32(txt_Out_Num.Text); money += Convert.ToInt32(txt_Out_Num.Text) * var.Prot_tradeprice; if (var.Store_sum - var.In_Out_StoreRoom < var.Store_lastNum) { MessageBox.Show("请注意,该商品销售后,该商品库存小于库存下线,请尽快进货", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } b = false; break; } } if (b) { s.In_Out_StoreRoom = Convert.ToInt32(txt_Out_Num.Text); num++; sum += s.In_Out_StoreRoom; money += s.In_Out_StoreRoom * s.Prot_retailprice; if (s.Store_sum - s.In_Out_StoreRoom < s.Store_lastNum) { MessageBox.Show("请注意,该商品销售后,该商品库存小于库存下线,请尽快进货", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } ls.Add(s); } common.s = null; dgv_Store.DataSource = null; dgv_Store.DataSource = ls; Clear(); txt_Prot_Name.Focus(); lb_money.Text = money.ToString(); lb_num.Text = num.ToString(); lb_sum.Text = sum.ToString(); } } catch (Exception) { MessageBox.Show("请输入正确的数字格式"); txt_Out_Num.SelectAll(); } } }
public ICollection <Party> findAllPartysByWeightAndVegetable(StoreRoom store, float weight, Vegetable vegetable) { throw new NotImplementedException(); }
public Party addParty(StoreRoom storeRoom, Party party) { storerooms[storeRoom.Name].AddParty(party); return(party); }