private void button13_Click(object sender, EventArgs e) { MainDashboard mm = new MainDashboard(userName); mm.Show(); this.Close(); }
private void btnCreate_Click(object sender, EventArgs e) { try { if (txt999.Text == string.Empty) { errorProvider1.Clear(); errorProvider1.SetError(txt999, "Enter Value."); txt999.Focus(); panel3.Visible = true; lblError.Text = "Enter Value."; } else if (txtHallMark.Text == string.Empty) { errorProvider1.Clear(); errorProvider1.SetError(txtHallMark, "Enter Value."); txtHallMark.Focus(); panel3.Visible = true; lblError.Text = "Enter Value."; } else if (txtBuyBack.Text == string.Empty) { errorProvider1.Clear(); errorProvider1.SetError(txtBuyBack, "Enter Value."); txtBuyBack.Focus(); panel3.Visible = true; lblError.Text = "Enter Value."; } else if (txt22c.Text == string.Empty) { errorProvider1.Clear(); errorProvider1.SetError(txt22c, "Enter Value."); txt22c.Focus(); panel3.Visible = true; lblError.Text = "Enter Value."; } else if (txt23c.Text == string.Empty) { errorProvider1.Clear(); errorProvider1.SetError(txt23c, "Enter Value."); txt23c.Focus(); panel3.Visible = true; lblError.Text = "Enter Value."; } else if (txt18c.Text == string.Empty) { errorProvider1.Clear(); errorProvider1.SetError(txt18c, "Enter Value."); txt18c.Focus(); panel3.Visible = true; lblError.Text = "Enter Value."; } else if (txtSilver.Text == string.Empty) { errorProvider1.Clear(); errorProvider1.SetError(txtSilver, "Enter Value."); txtSilver.Focus(); panel3.Visible = true; lblError.Text = "Enter Value."; } else { if (passedId == 0) { var todaysDate = DateTime.Now.Date; _entities = new MicroAccountsEntities1(); var data = _entities.DailyRates.Where(x => x.date == todaysDate).FirstOrDefault(); if (data == null) { _entities = new MicroAccountsEntities1(); DailyRate rates = new DailyRate(); rates.fineGold = Convert.ToDecimal(txt999.Text); rates.hallmark = Convert.ToDecimal(txtHallMark.Text); rates.hallmarkBuyBack = Convert.ToDecimal(txtBuyBack.Text); rates.twentyTwoC = Convert.ToDecimal(txt22c.Text); rates.twentyThreeC = Convert.ToDecimal(txt23c.Text); rates.eighteenC = Convert.ToDecimal(txt18c.Text); rates.silver = Convert.ToDecimal(txtSilver.Text); rates.date = DateTime.Now.Date; rates.createdDate = DateTime.Now; rates.updatedDate = DateTime.Now; _entities.DailyRates.Add(rates); _entities.SaveChanges(); MessageBox.Show("Record SuccessFully Added!"); clear(); MainDashboard mm = new MainDashboard(userName); mm.Show(); } else { DialogResult myResult; myResult = MessageBox.Show("Are you really wnat to update the Rates?", "Update Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (myResult == DialogResult.OK) { btnCreate.Text = "Update"; data.fineGold = Convert.ToDecimal(txt999.Text); data.hallmark = Convert.ToDecimal(txtHallMark.Text); data.hallmarkBuyBack = Convert.ToDecimal(txtBuyBack.Text); data.twentyTwoC = Convert.ToDecimal(txt22c.Text); data.twentyThreeC = Convert.ToDecimal(txt23c.Text); data.eighteenC = Convert.ToDecimal(txt18c.Text); data.silver = Convert.ToDecimal(txtSilver.Text); data.date = DateTime.Now.Date; data.createdDate = DateTime.Now; _entities.SaveChanges(); MessageBox.Show("Record SuccessFully Updated!"); clear(); MainDashboard mm = new MainDashboard(userName); mm.Show(); } else { MainDashboard mm = new MainDashboard(userName); mm.Show(); this.Close(); } } } else { btnCreate.Text = "Update"; _entities = new MicroAccountsEntities1(); var rates = _entities.DailyRates.Where(x => x.id == passedId).FirstOrDefault(); rates.fineGold = Convert.ToDecimal(txt999.Text); rates.hallmark = Convert.ToDecimal(txtHallMark.Text); rates.hallmarkBuyBack = Convert.ToDecimal(txtBuyBack.Text); rates.twentyTwoC = Convert.ToDecimal(txt22c.Text); rates.twentyThreeC = Convert.ToDecimal(txt23c.Text); rates.silver = Convert.ToDecimal(txtSilver.Text); rates.eighteenC = Convert.ToDecimal(txt18c.Text); rates.date = DateTime.Now.Date; rates.createdDate = DateTime.Now; _entities.SaveChanges(); MessageBox.Show("Record SuccessFully Updated!"); clear(); } } } catch (Exception c) { } }