예제 #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                if (num_workedHours.Value <= 0)
                {
                    MessageBox.Show("Working Hours must be grater than Zero", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (num_starttotalizer.Value >= num_EndTotalizer.Value)
                {
                    MessageBox.Show("Start totalizer value must grater than end totalizer value", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (num_starttotalizer.Value + 50 >= num_EndTotalizer.Value)
                {
                    MessageBox.Show("This pump's output value ( " + (num_EndTotalizer.Value - num_starttotalizer.Value).ToString() + " Liters ) is less than normal. ", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                int dayid    = commonFunctions.ToInt(cmb_days.SelectedValue.ToString());
                int pumperid = commonFunctions.ToInt(cmb_pumperForcashcol.SelectedValue.ToString());
                DailyAssignWorkerDetails det = (DailyAssignWorkerDetails)lst_nozzels.SelectedItems[0].Tag;
                if (det != null)
                {
                    if (!det.IsOpen)
                    {
                        MessageBox.Show("This nozzel already closed.", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (MessageBox.Show("Do you want to close this Nozzel?", Messaging.MessageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        CustomeRepository.InsetPumpClosing(
                            dayid,
                            det.PumperID,
                            det.NozzelID,
                            num_workedHours.Value,
                            num_starttotalizer.Value,
                            num_EndTotalizer.Value,
                            num_EndTotalizer.Value - num_starttotalizer.Value,
                            num_Price.Value,
                            (num_EndTotalizer.Value - num_starttotalizer.Value) * num_Price.Value,
                            det.SeqNo,
                            commonFunctions.ToInt(cmb_sessions.SelectedValue.ToString())
                            );

                        if (cmb_days.SelectedValue != null)
                        {
                            RefreshDailyAssignWorkerDetailList(commonFunctions.ToInt(cmb_days.SelectedValue.ToString()), commonFunctions.ToInt(cmb_sessions.SelectedValue.ToString()));
                        }

                        lbl_pumpername.Text     = "(....)";
                        lbl_pumpername.Text     = "(....)";
                        pnl_indicator.BackColor = Color.Red;
                        lbl_nozzsrtatus.Text    = "Closed";
                    }
                }
                else
                {
                    MessageBox.Show("Please select a one nozzel from the list for closing", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Has found when loading data. Please forword following details to technical" + Environment.NewLine + "[" + ex.Message + Environment.NewLine + ex.Source + "]", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }