private void btnFinishFix_Click(object sender, EventArgs e) { if(tanktofix.Id >0) { using (GazOnDevEntities db=new GazOnDevEntities()) { tanktofix.TankSystemStatus = "1"; db.Tank_Stocks.Attach(tanktofix); db.ObjectStateManager.ChangeObjectState(tanktofix, EntityState.Modified); // newrecord.TankSystemStatus = "3"; if (db.SaveChanges() > 0) { MessageBox.Show("פעולת סיום שיפוץ הצליחה "); // btnOpenTank.Enabled = false; } } }else { MessageBox.Show("נא לבחור צובר"); } }
private void button1_Click(object sender, EventArgs e) { // update selected.Count = txteditAmount.Text; using (GazOnDevEntities db = new GazOnDevEntities()) { db.Attach(selected); db.ObjectStateManager.ChangeObjectState(selected, EntityState.Modified); db.SaveChanges(); MessageBox.Show("נשמר בהצלחה "); } button1.Enabled = false; }
private void btnOpenTank_Click(object sender, EventArgs e) { //MessageBox.Show("הוספת פריט למלאי נלווה"); using (GazOnDevEntities db=new GazOnDevEntities()) { Accompanying_stocks newrecord = new Accompanying_stocks(); newrecord.Count = txtStockAmount.Text; newrecord.Title = txtStockTitle.Text; db.AddToAccompanying_stocks(newrecord); int result = db.SaveChanges(); if (result > 0) { MessageBox.Show("פריט התווסף למלאי בהצלחה "+result); } } }
private void button1_Click(object sender, EventArgs e) { // update selected.lastname = txtEditlastname.Text; selected.firstname = txtEditFirstname.Text; selected.username = txtEditusername.Text; selected.password = txtEditpassword.Text; selected.isadmin = chknewadmin.Checked; using (GazOnDevEntities db = new GazOnDevEntities()) { db.Attach(selected); db.ObjectStateManager.ChangeObjectState(selected, EntityState.Modified); db.SaveChanges(); MessageBox.Show("נשמר בהצלחה "); } button1.Enabled = false; }
private void btnOpenTank_Click(object sender, EventArgs e) { //MessageBox.Show("הוספת פריט למלאי נלווה"); using (GazOnDevEntities db=new GazOnDevEntities()) { user newrecord = new user(); newrecord.lastname = txtNewlastname.Text; newrecord.firstname = txtNewFirstname.Text; newrecord.username = txtNewusername.Text; newrecord.password = txtNewpass.Text; newrecord.isadmin = chknewadmin.Checked; db.AddTousers(newrecord); int result = db.SaveChanges(); if (result > 0) { MessageBox.Show(" פעולה הצליחה "); btnOpenTank.Enabled = false; } } }
private void btnOpenTank_Click(object sender, EventArgs e) { using (GazOnDevEntities db = new GazOnDevEntities()) { TankFixOperation newtankfixoperationrecord = new TankFixOperation(); newtankfixoperationrecord.tankID = tanktofix.Id; db.TankFixOperations.Where(x=>x.tankID == tanktofix.Id ).ToList().ForEach(db.TankFixOperations.DeleteObject); db.SaveChanges(); List<TankFixOperation> _opList = new List<TankFixOperation>(); foreach (ListViewItem item in Listview1.mobjListView.Items) { TankFixOperation row = new TankFixOperation(); row.tankID = tanktofix.Id; //ITERATE THROUGHT listview and save values to database tankFixoperation if (!string.IsNullOrEmpty(item.SubItems[1].ToString())) { row.amount = Convert.ToInt32(item.SubItems[1].ToString()); } if (!string.IsNullOrEmpty(item.SubItems[0].ToString())) { row.title = item.SubItems[0].ToString(); } if (!string.IsNullOrEmpty(item.SubItems[2].ToString())) { row.date = Convert.ToDateTime(item.SubItems[2].ToString()); } else { row.date = null; } if (!string.IsNullOrEmpty(item.SubItems[3].ToString())) { row.note = item.SubItems[3].ToString(); } _opList.Add(row); db.AddToTankFixOperations(row); // MessageBox.Show("Title" + item.SubItems[0].ToString()); } // הסתיים שיפוץ אזי יופיע במלאי tanktofix.TankSystemStatus = "3"; db.Tank_Stocks.Attach(tanktofix); db.ObjectStateManager.ChangeObjectState(tanktofix, EntityState.Modified); // db.Tank_Stocks.FirstOrDefault(x => x.TankNumber == textBox1.Text) //Tank_Stocks newrecord = new Tank_Stocks(); //newrecord.TankNumber = txtorderingName.Text; //newrecord.type = comboBox1.SelectedIndex.ToString(); //newrecord.Datetime = dateTimePicker1.Value; //this is a status of fixing progress // newrecord.TankSystemStatus = "3"; if (db.SaveChanges() > 0) { MessageBox.Show("פעולת ההוספה הצליחה"); // btnOpenTank.Enabled = false; } else { } } }
private void openFileDialog1_FileOk(object sender, CancelEventArgs e) { OpenFileDialog objOFD = sender as OpenFileDialog; if (sender == null || objOFD.Files == null || objOFD.Files.Count == 0) { return; } Gizmox.WebGUI.Common.Resources.FileHandle objFile = null; if (objOFD.Files[0] == null || !(objOFD.Files[0] is Gizmox.WebGUI.Common.Resources.FileHandle)) { return; } // Display original file name, of the first uploaded file, on a label. string newguid = Guid.NewGuid().ToString(); string path = ConfigurationManager.AppSettings["uploadfilepath"].ToString() +newguid; DirectoryInfo objDirectoryInfo = Directory.CreateDirectory(path); for (int intIndex = 0; intIndex < objOFD.Files.Count; intIndex++) { objOFD.Files[intIndex].SaveAs(Path.Combine(objDirectoryInfo.FullName, ((Gizmox.WebGUI.Common.Resources.HttpPostedFileHandle)(objOFD.Files[intIndex])).PostedFileName)); objFile = objOFD.Files[intIndex] as Gizmox.WebGUI.Common.Resources.FileHandle; LinkLabel linkLabel1 = new LinkLabel(); linkLabel1.Text = objFile.OriginalFileName; linkLabel1.Url = "files/" + newguid + "/" + objFile.OriginalFileName; flowLayoutPanel1.Controls.Add(linkLabel1); // ad values to database using (GazOnDevEntities db = new GazOnDevEntities()) { UploadedFilesOftank newfile = new UploadedFilesOftank(); newfile.filename = objFile.OriginalFileName; newfile.filepath = "files/" + newguid + "/" + objFile.OriginalFileName; newfile.tankfixid = tanktofix.Id.ToString(); db.AddToUploadedFilesOftanks(newfile); db.SaveChanges(); } } }
private void updateTankStock(string tankids,string invoicenumber) { int tankid = Convert.ToInt32(tankids); // update tankstock using (GazOnDevEntities db = new GazOnDevEntities()) { Tank_Stocks edittank = db.Tank_Stocks.SingleOrDefault(x => x.Id == tankid); edittank.invoiceid = invoicenumber; if (string.IsNullOrEmpty(invoicenumber)) { edittank.TankSystemStatus = "1"; } else { edittank.TankSystemStatus = "4"; } //db.Tank_Stocks.Attach(edittank); db.ObjectStateManager.ChangeObjectState(edittank, EntityState.Modified); db.SaveChanges(); } }
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(); } }
private void btnReportPrint_Click(object sender, EventArgs e) { using (GazOnDevEntities db = new GazOnDevEntities()) { if (edit) { db.Attach(_currentinvoice); db.ObjectStateManager.ChangeObjectState(_currentinvoice, EntityState.Modified); foreach (invoiceitem item in bindingSource1.List) { if (null != item.amount) { updateStockAmount(item); } db.Attach(item); db.ObjectStateManager.ChangeObjectState(item, EntityState.Modified); } } else { foreach (invoiceitem item in bindingSource1.List) { //invoiceitem item = new invoiceitem(); ////stocklist. // item.invoiceid = txtinvoiceid.Text; if (null != item.amount) { updateStockAmount(item); } db.AddToinvoiceitems(item); } } //} dbconf.invoicelastid = (Convert.ToInt32(dbconf.invoicelastid) + 1).ToString(); db.Attach(dbconf); db.ObjectStateManager.ChangeObjectState(dbconf, EntityState.Modified); if (edit) { } else { if (_currentinvoice == null) { _currentinvoice = new Invoice(); } _currentinvoice.address = txtAddress.Text; _currentinvoice.C_to = txtTo.Text; _currentinvoice.carnum = txtCarNum.Text; _currentinvoice.date = DatetimePicker.Value; _currentinvoice.invoiceNumber = txtinvoiceid.Text; _currentinvoice.tankNumber = tanktofix.TankNumber; _currentinvoice.tankDesc = txtTankDescription.Text; // increase invoice id number _currentinvoice.transporter = txtCarTransporter.Text; db.AddToInvoices(_currentinvoice); } if (db.SaveChanges() > 0) { // MessageBox.Show("פעולת ההוספה הצליחה"); frmReportTankRecipet tanko = new frmReportTankRecipet(Convert.ToInt32(_currentinvoice.invoiceNumber), "report3"); tanko.ShowDialog(); //btnOpenTank.Enabled = false; } else { MessageBox.Show("פעולת ההוספה נכשלה"); } } // btnOpenTank.Enabled = false; /* frmReportTankRecipet tanko = new frmReportTankRecipet(tanktofix.Id, "report3"); tanko.ShowDialog();*/ }
private void btnOpenTank_Click(object sender, EventArgs e) { using (GazOnDevEntities db = new GazOnDevEntities()) { if (edit) { db.Attach(newrecord); db.ObjectStateManager.ChangeObjectState(newrecord, EntityState.Modified); }else { newrecord = new Tank_Stocks(); newrecord.TankNumber = txtTankNumber.Text; newrecord.type = comboBox1.SelectedIndex.ToString(); newrecord.Datetime = txtdate1.Text; newrecord.GazCompanyName = txtGazCompanyName.Text; newrecord.GazCompanyAddress = txtGazCompanyAddress.Text; newrecord.GazDistributor = txtGazDistributor.Text; if (!string.IsNullOrEmpty(txtYear_of_manufacture.Text)) { newrecord.Year_of_manufacture = Convert.ToInt32(txtYear_of_manufacture.Text); } newrecord.Date_of_Fix = Date_Of_Fix.Text; newrecord.manufacture_name = txtmanufacture_name.Text; if (!string.IsNullOrEmpty(txt_Tank_Size.Text)) { newrecord.Tank_Size = txt_Tank_Size.Text; } if (!string.IsNullOrEmpty(txtLabel_Number.Text)) { newrecord.Label_Number =Convert.ToInt32(txtLabel_Number.Text); } newrecord.Address_Tank_From = txt_tank_fromAddress.Text; if (!string.IsNullOrEmpty(txtNumberOfZoklokPort.Text)) { newrecord.NumberOfZoklokPort = Convert.ToInt32(txtNumberOfZoklokPort.Text); } newrecord.tankStatus = combotankStatus.SelectedIndex.ToString(); newrecord.TankWithBase_baton = checkBox1.Checked ? true : false; // means that enabled at the stock newrecord.TankSystemStatus = "1"; db.AddToTank_Stocks(newrecord); dbconf.tanknumber = (Convert.ToInt32(dbconf.tanknumber) + 1).ToString(); db.Attach(dbconf); db.ObjectStateManager.ChangeObjectState(dbconf, EntityState.Modified); } if (db.SaveChanges() > 0) { MessageBox.Show("פעולת ההוספה הצליחה"); } else { } } }
private void button1_Click(object sender, EventArgs e) { // update int newamount = Convert.ToInt32(txteditAmount.Text) + Convert.ToInt32(txteditAmountCurrent.Text); selected.Count = newamount.ToString(); using (GazOnDevEntities db = new GazOnDevEntities()) { db.Attach(selected); db.ObjectStateManager.ChangeObjectState(selected, EntityState.Modified); db.SaveChanges(); MessageBox.Show("נשמר בהצלחה "); txteditAmount.Text = ""; //comboBox1.SelectedIndex = comboBox1.Items.IndexOf(selected); comboBox1.SelectedIndex = comboBox1.FindStringExact(selected.Title); } button1.Enabled = false; }
private void btnOpenTank_Click(object sender, EventArgs e) { using (GazOnDevEntities db = new GazOnDevEntities()) { if (string.IsNullOrEmpty(txtTankNumber.Text)) { MessageBox.Show("מספר צובר ריק נא להכניס מספר צובר תקין"); txtTankNumber.Text = ""; txtTankNumber.Focus(); return; } if(null !=newrecord) { if (string.IsNullOrEmpty(newrecord.TankNumber)) { MessageBox.Show("מספר צובר ריק נא להכניס מספר צובר תקין"); txtTankNumber.Text = ""; txtTankNumber.Focus(); return; } } if (null == newrecord) { edit = false; } if (edit) { // dbconf.tanknumber = (Convert.ToInt32(dbconf.tanknumber) + 1).ToString(); dbconf.tankfixformnum = (Convert.ToInt32(dbconf.tankfixformnum) + 1).ToString(); db.Attach(dbconf); db.ObjectStateManager.ChangeObjectState(dbconf, EntityState.Modified); db.Attach(newrecord); db.ObjectStateManager.ChangeObjectState(newrecord, EntityState.Modified); } else { newrecord = new Tank_Stocks(); } newrecord.TankNumber = txtTankNumber.Text; newrecord.TankFixNumber = txtfixnumber.Text; newrecord.type = comboBox1.SelectedIndex.ToString(); newrecord.Datetime = txtdate1.Text; newrecord.GazCompanyName = txtGazCompanyName.Text; newrecord.GazCompanyAddress = txtGazCompanyAddress.Text; newrecord.GazDistributor = txtGazDistributor.Text; if (!string.IsNullOrEmpty(txtYear_of_manufacture.Text)) { newrecord.Year_of_manufacture = Convert.ToInt32(txtYear_of_manufacture.Text); } newrecord.Date_of_Fix = Date_Of_Fix.Text; newrecord.manufacture_name = txtmanufacture_name.Text; if (!string.IsNullOrEmpty(txt_Tank_Size.Text)) { newrecord.Tank_Size =txt_Tank_Size.Text; } if (!string.IsNullOrEmpty(txtLabel_Number.Text)) { newrecord.Label_Number = Convert.ToInt32(txtLabel_Number.Text); } newrecord.Address_Tank_From = txt_tank_fromAddress.Text; if (!string.IsNullOrEmpty(txtNumberOfZoklokPort.Text)) { newrecord.NumberOfZoklokPort = Convert.ToInt32(txtNumberOfZoklokPort.Text); } newrecord.tankStatus = combotankStatus.SelectedIndex.ToString(); newrecord.TankWithBase_baton = checkBox1.Checked ? true : false; // means that enabled at the stock //status 2 means that the tank is ready for fix and not in the stock if (newrecord.TankSystemStatus != "3") { newrecord.TankSystemStatus = "2"; } //signed person if (!string.IsNullOrEmpty(txtName_of_recipient.Text)) { newrecord.PersonRecipetsignName = txtName_of_recipient.Text; } if (!string.IsNullOrEmpty(txtSign_of_recipient.Text)) { newrecord.PersonRecipetsignSigniture = txtSign_of_recipient.Text; } // transport Company if (!string.IsNullOrEmpty(txtTransportCompany.Text)) { newrecord.TransportCompanyName = txtTransportCompany.Text; } if (!string.IsNullOrEmpty(txtTransporterName.Text)) { newrecord.TransportCompanyTransportername = txtTransporterName.Text; } if (!string.IsNullOrEmpty(txtCarNumber.Text)) { newrecord.CarNumber = txtCarNumber.Text; } if (!edit) { dbconf.tanknumber = (Convert.ToInt32(dbconf.tanknumber) + 1).ToString(); dbconf.tankfixformnum = (Convert.ToInt32(dbconf.tankfixformnum) + 1).ToString(); db.Attach(dbconf); db.ObjectStateManager.ChangeObjectState(dbconf, EntityState.Modified); db.AddToTank_Stocks(newrecord); } if (db.SaveChanges() > 0) { MessageBox.Show("פעול הצליחה"); //foreach (Control item in this.Controls) //{ // item.Enabled = false; // //if(item.) //} //btnOpenTank.Enabled = false; } } }