public TankInvoice() { InitializeComponent(); dataGridView1.CellClick+=new DataGridViewCellEventHandler(dataGridView1_CellClick); dataGridView1.KeyDown +=new KeyEventHandler(dataGridView1_KeyDown); this.RightToLeft = Gizmox.WebGUI.Forms.RightToLeft.Yes; txtinvoiceid.Leave += new EventHandler(txtinvoiceid_Leave); txtTankNymber.Leave += new EventHandler(txtTankNymber_Leave); dataGridView1.AllowUserToAddRows = true; dataGridView1.ReadOnly = false; dataGridView1.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2; //dataGridView1.KeyDown+=new KeyEventHandler(dataGridView1_KeyDown); //dataGridView1.KeyPress += new KeyPressEventHandler(dataGridView1_KeyPress); using (GazOnDevEntities db= new GazOnDevEntities()) { dbconf= db.Configdbs.FirstOrDefault(); txtinvoiceid.Text = dbconf.invoicelastid; var query = from p in db.Accompanying_stocks where p.isininvoice == true orderby p.invoiceorder ascending select p; List<Accompanying_stocks> newstocklist = new List<Accompanying_stocks>(query.ToList<Accompanying_stocks>()); Accompanying_stocks temp=new Accompanying_stocks(); int k = 1; foreach (Accompanying_stocks item in newstocklist) { invoiceitem invitm=new invoiceitem(); invitm.invoiceid =txtinvoiceid.Text; invitm.title =item.Title; invitm.type = "stock"; invitm.typeid = item.Id.ToString(); invitm.num = k.ToString(); k++; _currentinvoiceitems.Add(invitm); } bindingSource1.DataSource = _currentinvoiceitems; //stocklist.Add(temp); //stocklist.Add(temp); // must icrease id of invoice id ; } // textBox1.Leave += new EventHandler(textBox1_Leave); }
private void updateStockAmount(invoiceitem item) { using (GazOnDevEntities db=new GazOnDevEntities()) { int idd=Convert.ToInt32(item.typeid); Accompanying_stocks tepstock = db.Accompanying_stocks.SingleOrDefault(x => x.Id == idd); int amount= Convert.ToInt32(tepstock.Count) - Convert.ToInt32(item.amount); tepstock.Count = amount.ToString(); var entry = db.ObjectStateManager.GetObjectStateEntry(tepstock); if (entry.State == EntityState.Detached) { // Do Something db.Attach(tepstock); } db.ObjectStateManager.ChangeObjectState(tepstock, EntityState.Modified); db.SaveChanges(); } }
void dd_FormClosing(object sender, FormClosingEventArgs e) { /* dtclmnid; dtclmnTitle; dtclmnAmount; dtclmnNote;*/ //_currentinvoiceitems.Add( invoiceitem newrow = new invoiceitem(); InvoiceControlAccompanyStockAdd ctrl = (InvoiceControlAccompanyStockAdd)sender; if (string.IsNullOrEmpty(ctrl.Title) || string.IsNullOrEmpty(ctrl.Amount)) return; int i; i = dataGridView1.Rows.Add( new DataGridViewRow()); DataGridViewCell cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl.Title; newrow.title = ctrl.Title; dataGridView1.Rows[i].Cells["dtclmnTitle"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl.Note; newrow.note = ctrl.Note; dataGridView1.Rows[i].Cells["dtclmnNote"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl.Amount; newrow.amount = Convert.ToInt32(ctrl.Amount); dataGridView1.Rows[i].Cells["dtclmnAmount"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = i+1; newrow.num = (i + 1).ToString(); dataGridView1.Rows[i].Cells["dtclmnid"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl._Type; newrow.type = ctrl._Type; dataGridView1.Rows[i].Cells["dttype"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl._Typeid; newrow.typeid = ctrl._Typeid; dataGridView1.Rows[i].Cells["dttypeid"] = cell1; DataGridViewButtonCell cell2 = new DataGridViewButtonCell(); cell2.Value = "מחיקה"; dataGridView1.Rows[i].Cells["dtbttndelet"] = cell2; _currentinvoiceitems.Add(newrow); /* cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl.Title; dataGridView1.Rows[i].Cells["Amount"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl.Title; dataGridView1.Rows[i].Cells["Title"] = cell1;*/ }
void dd2_FormClosing(object sender, FormClosingEventArgs e) { InvoiceControlTankStockAdd ctrl = (InvoiceControlTankStockAdd)sender; if (string.IsNullOrEmpty(ctrl.TankNumber)) return; int i; i = dataGridView1.Rows.Add(new DataGridViewRow()); DataGridViewCell cell1 = new DataGridViewTextBoxCell(); cell1.Value = "צובר "+ctrl.tankSize+" גלון מספר "+ctrl.TankNumber+""; dataGridView1.Rows[i].Cells["dtclmnTitle"] = cell1; invoiceitem newrow = new invoiceitem(); newrow.title = "צובר " + ctrl.tankSize + " גלון מספר " + ctrl.TankNumber + ""; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl.Note; newrow.note = ctrl.Note; dataGridView1.Rows[i].Cells["dtclmnNote"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl._Amount; newrow.amount = Convert.ToInt32(ctrl._Amount); dataGridView1.Rows[i].Cells["dtclmnAmount"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = i + 1; newrow.num = (i + 1).ToString(); dataGridView1.Rows[i].Cells["dtclmnid"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl._Type; newrow.type = ctrl._Type; dataGridView1.Rows[i].Cells["dttype"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl._Typeid; newrow.typeid = ctrl._Typeid; dataGridView1.Rows[i].Cells["dttypeid"] = cell1; _currentinvoiceitems.Add(newrow); if (ctrl._Type == "tank") { if (null == _currentinvoice) { updateTankStock(ctrl._Typeid, txtinvoiceid.Text); } else { updateTankStock(ctrl._Typeid, _currentinvoice.invoiceNumber); } havetank = true; } }
/// <summary> /// Deprecated Method for adding a new object to the invoiceitems EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToinvoiceitems(invoiceitem invoiceitem) { base.AddObject("invoiceitems", invoiceitem); }
/// <summary> /// Create a new invoiceitem object. /// </summary> /// <param name="id">Initial value of the id property.</param> public static invoiceitem Createinvoiceitem(global::System.Int32 id) { invoiceitem invoiceitem = new invoiceitem(); invoiceitem.id = id; return invoiceitem; }