private void cmdCloseComplaintGenerate_Click(object sender, System.EventArgs e)
        {
            try
            {
                /*checking whether given reference number exists or not */
                strCommandString = "select ref_num from complaints_new_tb where ref_num='" + txtCloseComplaintRefNum.Text + "'";
                bool blnResult = ComplaintsDB.CheckForExistance(strConnectionString, strCommandString);
                if (!blnResult)
                {
                    lblCloseComplaintRefNumMsg.Text = "Entered reference number doesn't exist";
                    return;
                }
                /* checking whether complaint with given reference number is tried for assignment or not */
                strCommandString = "select ref_num from complaints_assignment_tb where ref_num='" + txtCloseComplaintRefNum.Text + "'";
                blnResult        = ComplaintsDB.CheckForExistance(strConnectionString, strCommandString);
                if (!blnResult)
                {
                    lblCloseComplaintRefNumMsg.Text = "Complaint for given reference number is not yet assigned ";
                    return;
                }
                /*checking status of complaint with given reference number */
                strCommandString = "select status from complaints_assignment_tb where ref_num='" + txtCloseComplaintRefNum.Text + "'";
                string strStatus = ComplaintsDB.FetchScalar(strConnectionString, strCommandString);
                if (strStatus.Equals("PENDING"))
                {
                    lblCloseComplaintRefNumMsg.Text = "Complaint for given reference number is not yet assigned bcz of non availability of linemen";
                    return;
                }
                else if (strStatus.Equals("CLOSED"))
                {
                    lblCloseComplaintRefNumMsg.Text = "complaint already closed";
                    return;
                }
                /*retrieving assigned date and delay reason for entered reference number */
                strCommandString = "select assign_date,delay_reason from complaints_assignment_tb where ref_num='" + txtCloseComplaintRefNum.Text + "'";

                DataSet dataSet = ComplaintsDB.FetchDataSet(strConnectionString, strCommandString, "complaints_assignment_tb");

                txtCloseComplaintAssignedDate.Text = dataSet.Tables ["complaints_assignment_tb"].Rows [0]["assign_date"].ToString();
                txtCloseComplaintDelayReason.Text  = dataSet.Tables ["complaints_assignment_tb"].Rows [0]["delay_reason"].ToString();

                cmdCloseComplaintClose.Enabled = true;
            }
            catch (Exception exception)
            {
                lblCloseComplaintClosedDateMsg.Text = "insertion failed:" + exception.Message.ToString();
                return;
            }
        }
Exemplo n.º 2
0
        private void cmdLogin_Click(object sender, System.EventArgs e)
        {
            /*checking whether user is valid or not based on credentials entered*/
            strCommandString = "select user_id from complaints_users_tb where user_id='" + txtUserID.Text + "' and passwd='" + txtPasswd.Text + "'";
            bool blnResult = ComplaintsDB.CheckForExistance(strConnectionString, strCommandString);

            if (blnResult)            /*user exists */
            {
                /*creating session for user*/
                Session ["user_id"] = txtUserID.Text;
                if (int.Parse(txtUserID.Text) > 100)
                {
                    Response.Redirect("Welcome.html");
                }
                else
                {
                    Response.Redirect("Welcome_JE.aspx");
                }
            }
            else              /*user doesn't exist*/
            {
                Response.Write("Invalid User");
            }
        }
Exemplo n.º 3
0
        private void cmdAssignmentAssign_Click(object sender, System.EventArgs e)
        {
            /* checking whether given reference number is existing or not*/
            strCommandString = "select ref_num from complaints_new_tb where ref_num='" + txtAssignmentRefNum.Text + "'";
            bool blnResult = ComplaintsDB.CheckForExistance(strConnectionString, strCommandString);

            if (!blnResult)
            {
                lblAssignmentRefNumMsg.Text = "Entered complaint reference number doesn't exist";
                return;
            }
            /* checking whether assign date has choosen or not */
            if (cboAssignmentLinemanNum.Items.Count > 0)
            {
                if (txtAssignmentAssignDate.Text.ToString().Trim().Equals(""))
                {
                    lblAssignmentAssignDateMsg.Text = "Select assign date";
                    return;
                }
                /* comparing complaint given date and date to be assigned */
                /*fetching complaint given date for entered refernce number */
                lblAssignmentRefNumMsg.Text = "";
                strCommandString            = "select given_date from complaints_new_tb where ref_num='" + txtAssignmentRefNum.Text + "'";
                string strDate_first_string = ComplaintsDB.FetchScalar(strConnectionString, strCommandString);
                int    intFlag = ComplaintsDB.CompareDates(strConnectionString, strCommandString, txtAssignmentRefNum.Text, strDate_first_string, txtAssignmentAssignDate.Text, "complaints_validateDates_proc");
                if (intFlag < 0)              /* invalid assign date */
                {
                    lblAssignmentAssignDateMsg.Text = "date to be assigned is before complaint given date";
                    return;
                }
            }
            /* checking whether complaint with given reference number is considered for assignment */
            strCommandString = "select count(ref_num) from complaints_assignment_tb where ref_num='" + txtAssignmentRefNum.Text + "'";
            int intCount = ComplaintsDB.CheckForDuplicates(strConnectionString, strCommandString);

            if (intCount == 1)                                /*reference number existing and now cheking for 'PENDING' status */
            {
                if (cboAssignmentLinemanNum.Items.Count != 0) /* linemen available for assignment */
                {
                    try
                    {
                        /* if no lineman number is selected */
                        if (cboAssignmentLinemanNum.SelectedIndex <= 0)
                        {
                            Label1.Text = "select lineman number";
                            return;
                        }
                        /* checking whether complaint with given  reference number is already assigned or not*/
                        /* query for getting status for given reference number */
                        strCommandString = "select status from complaints_assignment_tb where ref_num='" + txtAssignmentRefNum.Text + "'";
                        /* getting status for given reference number */
                        string strStatus = ComplaintsDB.FetchScalar(strConnectionString, strCommandString);
                        if (strStatus.Equals("ALLOTTED") | strStatus.Equals("CLOSED"))
                        {
                            lblAssignmentMsg.Text = "Already assigned";
                            return;
                        }
                        /* not yet assigned */
                        /* assigning work to selected lineman and updating required fileds in assignment table */
                        strCommandString = "update complaints_assignment_tb set lineman_num='" + cboAssignmentLinemanNum.Items [cboAssignmentLinemanNum.SelectedIndex] + "',status='ALLOTTED',assign_date='" + txtAssignmentAssignDate.Text + "',delay_reason='delayed-no lineman is available' where ref_num='" + txtAssignmentRefNum.Text + "'";
                        ComplaintsDB.ChangeStatus(strConnectionString, strCommandString);
                        /* updating the status of selected lineman to 'ALLOTTED' */
                        strCommandString = "update complaints_linemen_tb set status='ALLOTTED' where lineman_num='" + cboAssignmentLinemanNum.Items [cboAssignmentLinemanNum.SelectedIndex] + "'";
                        ComplaintsDB.ChangeStatus(strConnectionString, strCommandString);
                        Response.Redirect("assignmentSuccess.aspx");
                    }
                    catch (Exception exception)
                    {
                        lblAssignmentMsg.Text = "insertion failed" + exception.Message.ToString();
                        return;
                    }
                }
                else
                {
                    lblAssignmentMsg.Text = "This complaint is already in pending status";
                    return;
                }
            }
            else                                              /* not already assigned */
            {
                if (cboAssignmentLinemanNum.Items.Count == 0) /* no lineman available to allot */
                {
                    // checking whether delay reason is entered
                    if (txtAssignmentDelayReason.Text.Trim().Equals(""))
                    {
                        lblAssignmentMsg.Text = "enter delay reason";
                        return;
                    }
                    /* query to perform insertion when no lineman is available */
                    strCommandString = "insert into complaints_assignment_tb values('" + txtAssignmentRefNum.Text + "',null,null,'" + txtAssignmentDelayReason.Text + "','PENDING')";
                }
                else                  /* lineman is available to allot */
                {
                    try
                    {
                        if (cboAssignmentLinemanNum.SelectedIndex < 1)                       /* if no lineman number is selected */
                        {
                            Label1.Text = "select lineman number";
                            return;
                        }
                        /*updating selected lineman status to 'ALLOTTED' */
                        strCommandString = "update complaints_linemen_tb set status='ALLOTTED' where lineman_num='" + cboAssignmentLinemanNum.Items [cboAssignmentLinemanNum.SelectedIndex] + "'";
                        ComplaintsDB.ChangeStatus(strConnectionString, strCommandString);
                        /*query to perform insertion when lineman is available */
                        strCommandString = "insert into complaints_assignment_tb values('" + txtAssignmentRefNum.Text + "','" + txtAssignmentAssignDate.Text + "','" + cboAssignmentLinemanNum.Items [cboAssignmentLinemanNum.SelectedIndex] + "',null,'ALLOTTED')";
                    }
                    catch (Exception exception)
                    {
                        lblAssignmentMsg.Text = "error while insertion:" + exception.Message.ToString();
                        return;
                    }
                }
                /* performing insertion */
                blnResult = ComplaintsDB.FetchBoolean(strConnectionString, strCommandString);
                if (blnResult)
                {
                    Response.Redirect("assignmentSuccess.aspx");
                }
                else
                {
                    Label1.Text = "failed";
                }
            }
        }