private void pull_item(DB.Item item) { dateTimePicker1.Value = item.Data; switch (item.Status) { case 0: checkedListBox1.SetItemChecked(0, true); break; case 1: checkedListBox1.SetItemChecked(1, true); break; case 2: checkedListBox1.SetItemChecked(2, true); break; } textBoxFIO.Text = item.Name; textBoxTel.Text = item.Tel; textBoxAdr.Text = item.Adr; textBoxImei.Text = item.Imei; textBoxBrand.Text = item.Brand; textBoxModel.Text = item.Model; richTextBox1.Text = item.Description; textBoxPrice.Text = item.Price; }
private async void dataGridView1_SelectionChanged(object sender, EventArgs e) { DB.Item item = new DB.Item(); var filter = Builders <DB.Item> .Filter.Eq("_id", ObjectId.Parse(dataGridView1[0, dataGridView1.CurrentRow.Index].Value.ToString())); using (var cursor = await DB.mongoCollection.FindAsync(filter)) { item = await cursor.FirstOrDefaultAsync(); if (item != null) { richTextBox2.Text = item.Description; richTextBox3.Text = item.Name; richTextBox4.Text = item.Imei; switch (item.Status) { case 0: btnDone.Enabled = true; btnIssue.Enabled = false; break; case 1: btnDone.Enabled = false; btnIssue.Enabled = true; break; case 2: btnDone.Enabled = false; btnIssue.Enabled = false; break; } } } }
private void push_item(DB.Item item) { item.Data = dateTimePicker1.Value.ToLocalTime(); //item.Status = 0; item.Name = textBoxFIO.Text; item.Tel = textBoxTel.Text; item.Adr = textBoxAdr.Text; item.Imei = textBoxImei.Text; item.Brand = textBoxBrand.Text; item.Model = textBoxModel.Text; item.Description = richTextBox1.Text; item.Price = textBoxPrice.Text; }
private async void btnOk_Click(object sender, EventArgs e) { DB.Item item = new DB.Item(); var filter = Builders <DB.Item> .Filter.Eq("", ""); switch (Form1.keyMode) { case "add": push_item(item); await DB.mongoCollection.InsertOneAsync(item); print_pdf(); break; case "edit": push_item(item); item.Id = Form1.curItem.Id; filter = Builders <DB.Item> .Filter.Eq("_id", ObjectId.Parse(Form1.curItem.Id.ToString())); await DB.mongoCollection.ReplaceOneAsync(filter, item); break; case "done": push_item(item); item.Status = 1; item.Id = Form1.curItem.Id; filter = Builders <DB.Item> .Filter.Eq("_id", ObjectId.Parse(Form1.curItem.Id.ToString())); await DB.mongoCollection.ReplaceOneAsync(filter, item); break; case "issue": push_item(item); item.Status = 2; item.Id = Form1.curItem.Id; filter = Builders <DB.Item> .Filter.Eq("_id", ObjectId.Parse(Form1.curItem.Id.ToString())); await DB.mongoCollection.ReplaceOneAsync(filter, item); break; } Close(); }
private void datagridadd(DB.Item listname) { dataGridView1.Rows.Add(listname.Id, listname.Status, listname.Data.ToShortDateString(), listname.Name, listname.Tel, listname.Adr, listname.Imei, listname.Brand, listname.Model, listname.Description, listname.Price); }