public async Task <IActionResult> PutWarehouse([FromRoute] int id, [FromBody] Models.Warehouse warehouse) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != warehouse.Id) { return(BadRequest()); } _context.Entry(warehouse).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WarehouseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostWarehouse([FromBody] Models.Warehouse warehouse) { this.ModelState.Remove("Id"); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Warehouses.Add(warehouse); await _context.SaveChangesAsync(); return(CreatedAtAction("GetWarehouse", new { id = warehouse.Id }, warehouse)); }
private void btnSave_Click(object sender, EventArgs e) { if (_warehouse == null) { var warehouse = FormData; _appContext.Warehouses.Add(warehouse); MessageBox.Show("Inserted"); } else { _warehouse.NameEN = txtNameEN.Text; _warehouse.NameKH = txtNameKH.Text; _warehouse.Phone = txtPhone.Text; _warehouse.Email = txtEmail.Text; _warehouse.Fax = txtFax.Text; _warehouse.Address = txtAddress.Text; _warehouse.Note = txtNote.Text; MessageBox.Show("Updated"); } _warehouse = null; _appContext.SaveChanges(); }
private void button1_Click(object sender, EventArgs e) { try { var id = int.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); _warehouse = _appContext.Warehouses.Find(id); if (_warehouse != null) { txtNameEN.Text = _warehouse.NameEN; txtNameKH.Text = _warehouse.NameKH; txtPhone.Text = _warehouse.Phone; txtEmail.Text = _warehouse.Email; txtFax.Text = _warehouse.Fax; txtNote.Text = _warehouse.Note; txtAddress.Text = _warehouse.Address; } tabControl1.SelectedIndex = 0; } catch (Exception exception) { MessageBox.Show("Error :" + exception); } }
private void btnSave_Click(object sender, EventArgs e) { if (!utils.requieredTextValidator(tbName, true)) { return; } if (!utils.requieredTextValidator(tbAddress, true)) { return; } if (btnSave.Text == "Guardar") { var datos = db.Warehouses.FirstOrDefault(x => x.name == tbName.Text); if (datos != null) { MessageBox.Show("Almacén existente", "Control de Inventario", MessageBoxButtons.OK, MessageBoxIcon.Warning); tbName.Focus(); return; } var warehouse = new Models.Warehouse { name = tbName.Text, address = tbAddress.Text, id_district = 0 }; db.Warehouses.Add(warehouse); db.SaveChanges(); MessageBox.Show("Almacén creado con éxito", "Control de Inventario", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { var datos2 = db.Warehouses.FirstOrDefault(x => x.name == tbName.Text && x.id == id); if (datos2 != null) { MessageBox.Show("Almacén existente", "Control de Inventario", MessageBoxButtons.OK, MessageBoxIcon.Warning); tbName.Focus(); return; } var warehouseEdit = db.Warehouses.FirstOrDefault(x => x.id == id); if (warehouseEdit != null) { warehouseEdit.name = tbName.Text; warehouseEdit.address = tbAddress.Text; db.Entry(warehouseEdit).State = EntityState.Modified; db.SaveChanges(); MessageBox.Show("Almacén actualizado con éxito", "Control de Inventario", MessageBoxButtons.OK, MessageBoxIcon.Information); } } btnNew.Visible = true; btnEdit.Visible = false; btnSave.Visible = false; btnCancel.Visible = false; utils.control_enable_all_textbox(this, false, true); fillDgv(); }
public System.Threading.Tasks.Task <int> AddSavingAsync(Models.Saving saving, Models.Warehouse warehouse) { return(base.Channel.AddSavingAsync(saving, warehouse)); }
public int AddSaving(Models.Saving saving, Models.Warehouse warehouse) { return(base.Channel.AddSaving(saving, warehouse)); }
public System.Threading.Tasks.Task <int> UpdateWarehouseAsync(Models.Warehouse warehouse) { return(base.Channel.UpdateWarehouseAsync(warehouse)); }
public int UpdateWarehouse(Models.Warehouse warehouse) { return(base.Channel.UpdateWarehouse(warehouse)); }
public int AddWarehouse(Models.Warehouse warehouse) { return(base.Channel.AddWarehouse(warehouse)); }
void thread() { DataTable warehouseData = getAllWarehouseData(); int total = warehouseData.Rows.Count; // esrcibo en el nowin porque van para premiumsoft foreach (DataRow row in warehouseData.Rows) { string FileName = "GP_TDEPO_{0}.xml"; string LOCNCODE = row["LOCNCODE"].ToString().Trim(); string LOCNDSCR = row["LOCNDSCR"].ToString().Trim(); IEvent e = new InfoEvent("", "", "Iniciando la creación del archivo XML '" + String.Format(FileName, LOCNCODE) + "'."); e.Publish(); // xml // XmlDocument doc = new XmlDocument(); /* Lines */ XmlElement Raiz = doc.CreateElement(string.Empty, "raiz", string.Empty); /* Lines */ try { Models.Warehouse ware = new Models.Warehouse(); //XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); //XmlElement root = doc.DocumentElement; //doc.InsertBefore(xmlDeclaration, root); //doc.AppendChild(Raiz); //XmlElement element2 = doc.CreateElement(string.Empty, "warehouse", string.Empty); //Raiz.AppendChild(element2); //XmlElement element3 = doc.CreateElement(string.Empty, "codigo", string.Empty); ware.Codigo = LOCNCODE.Trim(); // XmlText text1 = doc.CreateTextNode(LOCNCODE.Trim()); //element3.AppendChild(text1); //element2.AppendChild(element3); //XmlElement element4 = doc.CreateElement(string.Empty, "descripcion", string.Empty); ware.Descripcion = LOCNDSCR.Trim(); //XmlText text2 = doc.CreateTextNode(LOCNDSCR.Trim()); //element4.AppendChild(text2); //element2.AppendChild(element4); if (this.NowPathIn.ToCharArray().Last() == '/' || this.NowPathIn.ToCharArray().Last() == '\\') { if (!System.IO.File.Exists(this.mNowPathOut + string.Format(FileName, LOCNCODE))) { Models.Warehouse.SaveAs(this.mNowPathOut + string.Format(FileName, LOCNCODE), ware); //doc.Save(this.mNowPathOut + string.Format(FileName, LOCNCODE)); } } else { if (!System.IO.File.Exists(this.mNowPathOut + "/" + string.Format(FileName, LOCNCODE))) { Models.Warehouse.SaveAs(this.mNowPathOut + "/" + string.Format(FileName, LOCNCODE), ware); //doc.Save(this.mNowPathOut + "/" + string.Format(FileName, LOCNCODE)); } } total--; ObserverManager.Instance.addSubject(new ProgressSubject(total, warehouseData.Rows.Count - total)); IEvent e2 = new InfoEvent("", "", "El archivo '" + String.Format(FileName, LOCNCODE) + "'. fue creado correctamente"); e2.Publish(); } catch (Exception ex) { IEvent err = new ErrorEvent("", "", "No pudo crear el archivo xml correctamente. Mensaje: " + ex.Message); err.Publish(); } } ObserverManager.Instance.addSubject(new ProgressSubject(0, 0)); }
public static Warehouse From(Models.Warehouse source) { return(new Warehouse().PopulateWith(source)); }