private void btn_save_Click(object sender, EventArgs e) { if (Calculate()) { MessageBox.Show("New totalizer reaing must grater than existing reading.", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { if (CustomeRepository.CheckExistanceOFNozzelForDayInTotalizer(commonFunctions.ToInt(cmb_days.SelectedValue.ToString()), commonFunctions.ToInt(cmb_Nozzels.SelectedValue.ToString()))) { MessageBox.Show("Record already Exist for this nozzel .", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!ValidateInput()) { return; } TotalizeReading type = new TotalizeReading(); type.Id = int.Parse(lbl_id.Text.Trim()); type.NozzelID = commonFunctions.ToInt(cmb_Nozzels.SelectedValue.ToString()); type.DayID = commonFunctions.ToInt(cmb_days.SelectedValue.ToString()); type.CussreentReading = txt_exreading.Value; type.NewReading = txt_creading.Value; type.SIH = commonFunctions.ToDecimal(txt_qty.Text.Trim()); type.UPrice = commonFunctions.ToDecimal(txt_price.Text.Trim()); type.Value = commonFunctions.ToDecimal(txt_total.Text.Trim()); type.ShiftID = commonFunctions.ToInt(cmb_Shifts.SelectedValue.ToString()); type.GroupOfCompanyID = 1; type.ModifiedUser = commonFunctions.LoginuserID; type.ModifiedDate = DateTime.Now; type.CreatedUser = commonFunctions.LoginuserID; type.CreatedDate = DateTime.Now; type.DataTransfer = 1; if (MessageBox.Show("Do you want to insert this record?", Messaging.MessageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { repo.Save(type); GetData(); } } catch (Exception ex) { MessageBox.Show("Error Has found when Saving data. Please forword following details to technical" + Environment.NewLine + "[" + ex.Message + Environment.NewLine + ex.Source + "]", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void NavigateDataGrid(string v) { try { TotalizeReading type = repo.Get(int.Parse(v.Trim())); if (type != null) { lbl_id.Text = type.Id.ToString(); cmb_Nozzels.SelectedValue = type.NozzelID; txt_creading.Value = type.NewReading; txt_exreading.Value = type.CussreentReading; txt_qty.Text = type.SIH.ToString(); txt_price.Text = type.UPrice.ToString(); txt_total.Text = type.Value.ToString(); } } catch (Exception ex) { } }