Example #1
0
        private void btn_assignPumper_Click(object sender, EventArgs e)
        {
            if (cmb_pumper.SelectedValue == null)
            {
                MessageBox.Show("Please select a Pumper from the list", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lst_nozzels.SelectedItems.Count > 0)
            {
                DailyAssignWorkerDetails det = (DailyAssignWorkerDetails)lst_nozzels.SelectedItems[0].Tag;

                if (CustomeRepository.IsNozzelAssignedOn(det.DayID, commonFunctions.ToInt(cmb_sessions.SelectedValue.ToString()), det.NozzelID) > 0)
                {
                    MessageBox.Show("You cannot assign a Pumper to this nozzel on this Session. Please select differant Session", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (MessageBox.Show("Do you want to Assign this pumper?", Messaging.MessageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (commonFunctions.ToInt(cmb_pumper.SelectedValue.ToString()) > 0)
                    {
                        string message = CustomeRepository.AssignPumperToNozzel(det.DayID, commonFunctions.ToInt(cmb_pumper.SelectedValue.ToString()), det.NozzelID, det.DayWorkerID, commonFunctions.ToInt(cmb_sessions.SelectedValue.ToString()));
                        if (cmb_days.SelectedValue != null)
                        {
                            try
                            {
                                RefreshDailyAssignWorkerDetailList(commonFunctions.ToInt(cmb_days.SelectedValue.ToString()), commonFunctions.ToInt(cmb_sessions.SelectedValue.ToString()));
                                MessageBox.Show(message, Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                    }
                }
            }
        }