Jfisher387
Member
- Joined
- Dec 14, 2022
- Messages
- 21
- Programming Experience
- Beginner
Hello all,
Working on inventory software for in house use at my machine shop i work at. I have been working on this and learning c# for over a year now. Still a long road to go. Currently I have a DGV that we perform transactions on to change the qty of our in house tooling. and if it falls below my stock qty then we add to our order qty. pretty simple.
this has been in use for months now, not to many notable issues. today i noticed some of the newer tooling in the list wont update the qtys no matter what i try. I'm using a MongoDB to store all the data. I cannot find a reason some lines would work and some wont.
the only differences i can think of is that the newer tooling i added in with a in app feature (called "add tool"), whereas older tooling was added directly into a json file. i see no difference in the structure of the two different input methods.
My hunch is there is a setting for the DGV itself in visual studio that is limiting access or something to the lower rows. But a quick look there and i dont see much of an option to look into more.
I can post pictures, code etc. but not sure where to start. ill attach a few possible culprits below just in case.
**EDIT**
it is working to alter the qty's directly in the DB. and it will update as it should in the software based on the DB so it is reading all the data in properly. just isnt liking manipulating some of the info from the prompts..
Working on inventory software for in house use at my machine shop i work at. I have been working on this and learning c# for over a year now. Still a long road to go. Currently I have a DGV that we perform transactions on to change the qty of our in house tooling. and if it falls below my stock qty then we add to our order qty. pretty simple.
this has been in use for months now, not to many notable issues. today i noticed some of the newer tooling in the list wont update the qtys no matter what i try. I'm using a MongoDB to store all the data. I cannot find a reason some lines would work and some wont.
the only differences i can think of is that the newer tooling i added in with a in app feature (called "add tool"), whereas older tooling was added directly into a json file. i see no difference in the structure of the two different input methods.
My hunch is there is a setting for the DGV itself in visual studio that is limiting access or something to the lower rows. But a quick look there and i dont see much of an option to look into more.
I can post pictures, code etc. but not sure where to start. ill attach a few possible culprits below just in case.
ToolPull Function:
private void ToolPull_Click(object sender, EventArgs e)
{
if (transactionSerial_Box.Text.Length != 4)
{
MessageBox.Show("Serial number must be 4 digits. Please try again.", "invalid serial number", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
//define transaction variables
string serialSearch = transactionSerial_Box.Text;
const bool returnTool = false;
const bool toolBreak = false;
int transQty = Convert.ToInt32(numericUpDown1.Value);
DateTime timeNow = DateTime.Now;
int rowIndex = -1;
Object onHand;
//searching for a serial match in each row
foreach (DataGridViewRow row in toolingGridView.Rows)
{
if (Convert.ToString(row.Cells[1].Value) != serialSearch) continue;
//qty too low.. can't pull
if (Convert.ToInt32(row.Cells[5].Value) < transQty)
{
MessageBox.Show("On hand Quantity is less than transaction Quantity. Cannot pull Tool");
return;
}
toolingGridView.ClearSelection();
rowIndex = row.Index;
toolingGridView.Rows[rowIndex].Selected = true;
onHand = Convert.ToInt32(row.Cells[5].Value) - transQty;
row.Cells[5].Value = onHand;
int order = Convert.ToInt32(row.Cells[6].Value) - Convert.ToInt32(row.Cells[5].Value);
if (order <= 0)
{
order = 0;
}
var filter = Builders<Tool>.Filter.Eq("Serial", Convert.ToString(serialSearch));
var update = Builders<Tool>.Update.Set("On Hand Qty", Convert.ToInt32(onHand));
var orderUpdate = Builders<Tool>.Update.Set("Order Qty", order);
var result = toolCollection.UpdateOne(filter, update);
var orderResult = toolCollection.UpdateOne(filter, orderUpdate);
var trans = new Transaction(
(ObjectId)(row.Cells[0].Value),
Convert.ToInt32(row.Cells[1].Value),
Convert.ToDouble(row.Cells[2].Value),
CurrentEmployee.GetEmployee(),
Convert.ToString(row.Cells[8].Value),
Convert.ToString(row.Cells[9].Value),
Convert.ToString(row.Cells[10].Value),
Convert.ToString(row.Cells[11].Value),
Convert.ToDouble(row.Cells[12].Value),
Convert.ToDouble(row.Cells[13].Value),
timeNow,
returnTool,
toolBreak,
transQty);
transactionsCollection.InsertOne(trans);
}
}
//clear the input boxes after each entry. regardless if it was a valid transaction or not.
ClearInputBoxes();
this.ActiveControl = transactionSerial_Box;
employeeToolCostLabel.Text = Convert.ToString(EmployeeBalance());
UpdateFunction();
}
UpdateFunction & ReadData Function:
public void UpdateFunction()
{
ReadData();
UpdateOrderDGV();
ResizeColumns();
TotalStockCosting();
}
public void ReadData()
{
List<Tool> list = toolCollection.AsQueryable().ToList();
toolingGridView.DataSource = list;
}
**EDIT**
it is working to alter the qty's directly in the DB. and it will update as it should in the software based on the DB so it is reading all the data in properly. just isnt liking manipulating some of the info from the prompts..