Пример #1
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        int  recordUpdated   = 0;
        bool isDataSendtoNav = false;

        if (txtPassword.Value != "" && txtConfirmPassword.Value != null && txtOldPassword.Value != null)
        {
            if (txtPassword.Value.Trim() == txtConfirmPassword.Value.Trim())
            {
                using (SqlConnection con = new SqlConnection())
                {
                    con.ConnectionString = BusinessLayerClasses.ConnectionString.GetConnectionString();
                    con.Open();
                    SqlCommand     cmd = new SqlCommand("TMS_sp_ChangePassword");
                    SqlTransaction transaction;
                    transaction     = con.BeginTransaction(IsolationLevel.ReadUncommitted);
                    cmd.Connection  = con;
                    cmd.Transaction = transaction;
                    #region Transaction
                    try
                    {
                        cmd.CommandTimeout = 0;
                        cmd.CommandType    = CommandType.StoredProcedure;
                        SqlParameter parm = new SqlParameter("@Result", SqlDbType.Int);
                        parm.Direction = ParameterDirection.ReturnValue;
                        cmd.Parameters.Add(parm);
                        cmd.Parameters.AddWithValue("@OldPassword", objCrypto.Encrypt(txtOldPassword.Value.Trim()));
                        cmd.Parameters.AddWithValue("@NewPassword", objCrypto.Encrypt(txtPassword.Value.Trim()));
                        cmd.Parameters.AddWithValue("@Username", Session["UserName"].ToString());
                        cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(Session["ID"]));
                        cmd.Parameters.AddWithValue("@Result", 0);

                        cmd.ExecuteNonQuery();
                        recordUpdated = Convert.ToInt16(parm.Value);

                        if (recordUpdated == 1)
                        {
                            //Send updated Data to Nav
                            SendDatatoNAV objsenddatatonav = new SendDatatoNAV();
                            isDataSendtoNav = objsenddatatonav.SendPortalUserDatatoNav(Session["ID"].ToString(), Session["UserName"].ToString());
                        }
                        else if (recordUpdated == 0)
                        {
                            lblmsg.Text    = "Old Password is not Correct";
                            lblmsg.Visible = true;
                        }
                        else
                        {
                            lblmsg.Text    = "Some Error Occurs at the moment, Please try again or contact Administrator";
                            lblmsg.Visible = true;
                            btnOk.Visible  = false;
                        }
                    }
                    catch (Exception ex1)
                    {
                        try
                        {
                            transaction.Rollback(); //manual
                            ResetForm();            // Reset form
                            con.Close();
                            lblmsg.Text    = ex1.Message;
                            lblmsg.Visible = true;
                            return;
                        }
                        catch (Exception ex2)
                        {
                            lblmsg.Text    = ex2.Message;
                            lblmsg.Visible = true;
                        }
                    }
                    #endregion

                    #region Commit Transaction
                    if (recordUpdated > 0 && isDataSendtoNav == true)
                    {
                        transaction.Commit();
                        con.Close();
                        Response.Redirect("Login.aspx?s=1");  //moved to Login page again
                    }
                    else
                    {
                        transaction.Rollback();
                        ResetForm(); // Reset form
                        con.Close();
                        lblmsg.Text    = "Sorry, Operation cannot be performed , Please contact Administrator !! ";
                        lblmsg.Visible = true;
                    }
                    #endregion
                }
            }
        }
    }
Пример #2
0
    private void SubmitCIPLRequest()
    {
        DataTable dt = new DataTable();

        dt.Columns.Add(new DataColumn("ID"));
        dt.Columns.Add(new DataColumn("ReqNo"));  //commented by anu - As status updation no longer needed
        dt.Columns.Add(new DataColumn("Transporter Response"));
        dt.Columns.Add(new DataColumn("Cancellation Reason Code"));
        dt.Columns.Add(new DataColumn("Ready for Sending"));
        dt.Columns.Add(new DataColumn("Cancellation Remarks"));

        foreach (GridViewRow row in grdPlacedRequest.Rows)
        {
            string       RowDatakey           = grdPlacedRequest.DataKeys[row.RowIndex].Value.ToString();
            DropDownList ddlReasonCode        = row.FindControl("ddlReasonCode") as DropDownList;
            TextBox      txtTransporterRemark = row.FindControl("txtTransporterRemark") as TextBox;
            TextBox      txtcancelRemark      = row.FindControl("txtCancellationRemark") as TextBox;
            CheckBox     chkSelect            = row.FindControl("chkSelectedRow") as CheckBox;

            if (chkSelect.Checked)
            {
                DataRow dr = dt.NewRow();
                dr["ID"]    = RowDatakey;
                dr["ReqNo"] = grdPlacedRequest.Rows[row.RowIndex].Cells[0].Text;
                dr["Transporter Response"]     = ""; //No use in SP
                dr["Cancellation Reason Code"] = ddlReasonCode.SelectedItem.Value;
                dr["Ready for Sending"]        = 1;  // to be discuss for CIPL //rigt now not used in SP - No updation performed
                dr["Cancellation Remarks"]     = txtcancelRemark.Text;
                dt.Rows.Add(dr);
            }
        }
        if (dt.Rows.Count > 0)
        {
            using (SqlConnection con = new SqlConnection())
            {
                con.ConnectionString = BusinessLayerClasses.ConnectionString.GetConnectionString();
                con.Open();
                SqlCommand     cmd = new SqlCommand("TMS_sp_update_Pending_Request_for_CIPL");
                SqlTransaction transaction;
                transaction     = con.BeginTransaction(IsolationLevel.ReadUncommitted); // Start a local transaction.
                cmd.Connection  = con;
                cmd.Transaction = transaction;
                #region Transaction
                try
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandType    = CommandType.StoredProcedure;
                    SqlParameter sqlParameter = cmd.Parameters.AddWithValue("@TMSRequestUpdateTable", dt);
                    sqlParameter.SqlDbType = SqlDbType.Structured;
                    int rowaffected = cmd.ExecuteNonQuery();
                    foreach (DataRow dr1 in dt.Rows)
                    {
                        SendDatatoNAV objSendDatatoNAV = new SendDatatoNAV(dr1[1].ToString()); //commented on 06 sep by recommendation of Brijesh
                    }
                    //SEND EMAIL
                    transaction.Commit();
                    con.Close();
                    //Edited by vijay
                    BindGrid("", txtrequestno.Text, txttransportercode.Text);
                    lblErr.Text      = "Canceled Successfully";
                    lblErr.Visible   = true;
                    lblErr.ForeColor = System.Drawing.Color.Green;
                }
                catch (Exception ex1)
                {
                    try
                    {
                        transaction.Rollback(); //manual
                        con.Close();
                        lblErr.Text    = ex1.Message;
                        lblErr.Visible = true;
                    }
                    catch (Exception ex2)
                    {
                        lblErr.Text    = ex2.Message;
                        lblErr.Visible = true;
                    }
                }
                #endregion
            }
        }
    }
    private void SubmitCIPLRequest(string RowDatakey, GridViewRow row)
    {
        DataTable dt = new DataTable();

        dt.Columns.Add(new DataColumn("ID"));
        dt.Columns.Add(new DataColumn("ReqNo"));  //commented by anu - As status updation no longer needed
        dt.Columns.Add(new DataColumn("Transporter Response"));
        dt.Columns.Add(new DataColumn("Cancellation Reason Code"));
        dt.Columns.Add(new DataColumn("Ready for Sending"));
        dt.Columns.Add(new DataColumn("Cancellation Remarks"));

        DropDownList ddlReasonCode = row.FindControl("ddlReasonCode") as DropDownList;

        // CheckBox chkSelectedRow = row.FindControl("chkSelectedRow") as CheckBox;
        TextBox txtTransporterRemark = row.FindControl("txtTransporterRemark") as TextBox;

        if (ddlReasonCode.SelectedIndex != 0 || ddlReasonCode.SelectedItem.Text != "")
        {
            DataRow dr = dt.NewRow();
            dr["ID"]    = RowDatakey;
            dr["ReqNo"] = grdPendingRequest.Rows[row.RowIndex].Cells[0].Text;
            dr["Transporter Response"]     = ""; //No use in SP
            dr["Cancellation Reason Code"] = ddlReasonCode.SelectedItem.Value;
            dr["Ready for Sending"]        = 1;  // to be discuss for CIPL //rigt now not used in SP - No updation performed
            dr["Cancellation Remarks"]     = txtTransporterRemark.Text;
            dt.Rows.Add(dr);
        }

        /****************************************************************** DataTable to send Mail data from stored procedure ***********************/
        DataTable dtForMail = new DataTable();

        dtForMail.Columns.Add(new DataColumn("ReqNo"));
        DataRow dr1 = dtForMail.NewRow();

        dr1["ReqNo"] = grdPendingRequest.Rows[row.RowIndex].Cells[0].Text;
        dtForMail.Rows.Add(dr1);

        /**********************************************************************************************************************************************/

        if (dt.Rows.Count > 0)
        {
            using (SqlConnection con = new SqlConnection())
            {
                con.ConnectionString = BusinessLayerClasses.ConnectionString.GetConnectionString();
                con.Open();
                SqlCommand     cmd = new SqlCommand("TMS_sp_update_Pending_Request_for_CIPL");
                SqlTransaction transaction;
                transaction     = con.BeginTransaction(IsolationLevel.ReadUncommitted);  // Start a local transaction.
                cmd.Connection  = con;
                cmd.Transaction = transaction;
                #region Transaction
                try
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandType    = CommandType.StoredProcedure;
                    SqlParameter sqlParameter = cmd.Parameters.AddWithValue("@TMSRequestUpdateTable", dt);
                    sqlParameter.SqlDbType = SqlDbType.Structured;
                    int rowaffected = cmd.ExecuteNonQuery();

                    SendDatatoNAV objSendDatatoNAV = new SendDatatoNAV(dt.Rows[0][1].ToString());
                    transaction.Commit();
                    con.Close();
                    BindGridview("", "");
                    lblmsg.Text      = " Canceled Successfully";
                    lblmsg.Visible   = true;
                    lblmsg.ForeColor = System.Drawing.Color.Green;
                    SendMailToTransporter(dtForMail);      // send email
                }
                catch (Exception ex1)
                {
                    try
                    {
                        transaction.Rollback();      //manual
                        con.Close();
                        lblmsg.Text    = ex1.Message;
                        lblmsg.Visible = true;
                    }
                    catch (Exception ex2)
                    {
                        lblmsg.Text    = ex2.Message;
                        lblmsg.Visible = true;
                    }
                }
                #endregion
            }
        }
    }
    private void SubmitTransporterRequest()
    {
        DataTable dt = new DataTable();

        dt.Columns.Add(new DataColumn("ID"));
        dt.Columns.Add(new DataColumn("ReqNo"));
        dt.Columns.Add(new DataColumn("Transporter Response"));
        dt.Columns.Add(new DataColumn("Cancellation Reason Code"));
        dt.Columns.Add(new DataColumn("Ready for Sending"));
        dt.Columns.Add(new DataColumn("Cancellation Remarks"));

        foreach (GridViewRow row in grdPendingRequest.Rows)
        {
            string       key = grdPendingRequest.DataKeys[row.RowIndex].Value.ToString();
            DropDownList ddlTransporterResponse = row.FindControl("ddlTransporterResponse") as DropDownList;
            DropDownList ddlReasonCode          = row.FindControl("ddlReasonCode") as DropDownList;
            //ddlReasonCode.SelectedIndex
            CheckBox chkSelectedRow = row.FindControl("chkSelectedRow") as CheckBox;


            TextBox txtTransporterRemark = row.FindControl("txtTransporterRemark") as TextBox;

            if (chkSelectedRow.Checked)
            {
                //Label lblTransporterResponse = row.FindControl("lblTransporterResponse") as Label;
                //if (ddlTransporterResponse.SelectedIndex == 0) // nothing selected
                //{
                //    lblTransporterResponse.Text = "Please select Transporter Response";
                //    lblTransporterResponse.Visible = true;
                //    return;
                //}

                DataRow dr = dt.NewRow();
                dr["ID"]    = key;
                dr["ReqNo"] = grdPendingRequest.Rows[row.RowIndex].Cells[0].Text;
                dr["Transporter Response"] = ddlTransporterResponse.SelectedItem.Text;
                // string a = ddlReasonCode.SelectedItem.Value;
                if (Session["UserType"].ToString() == "Transporter")
                {
                    dr["Cancellation Reason Code"] = "";
                }
                else
                {
                    dr["Cancellation Reason Code"] = ddlReasonCode.SelectedItem.Value;
                }
                dr["Ready for Sending"]    = chkSelectedRow.Checked ? 1 : 0;
                dr["Cancellation Remarks"] = txtTransporterRemark.Text;
                dt.Rows.Add(dr);
            }
        }

        /****************************************************************** DataTable to get Mail data from stored procedure ***********************/
        DataTable dtForMail = new DataTable();

        dtForMail.Columns.Add(new DataColumn("ReqNo"));
        foreach (GridViewRow row1 in grdPendingRequest.Rows)
        {
            string   key            = grdPendingRequest.DataKeys[row1.RowIndex].Value.ToString();
            CheckBox chkSelectedRow = row1.FindControl("chkSelectedRow") as CheckBox;
            if (chkSelectedRow.Checked)
            {
                DataRow dr1 = dtForMail.NewRow();
                dr1["ReqNo"] = grdPendingRequest.Rows[row1.RowIndex].Cells[0].Text;
                dtForMail.Rows.Add(dr1);
            }
        }


        if (dt.Rows.Count > 0)
        {
            using (SqlConnection con = new SqlConnection())
            {
                con.ConnectionString = BusinessLayerClasses.ConnectionString.GetConnectionString();
                con.Open();
                SqlCommand     cmd = new SqlCommand("TMS_sp_update_Pending_Request");
                SqlTransaction transaction;
                transaction     = con.BeginTransaction(IsolationLevel.ReadUncommitted); // Start a local transaction.
                cmd.Connection  = con;
                cmd.Transaction = transaction;
                #region Transaction
                try
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandType    = CommandType.StoredProcedure;
                    SqlParameter sqlParameter = cmd.Parameters.AddWithValue("@TMSRequestUpdateTable", dt);
                    sqlParameter.SqlDbType = SqlDbType.Structured;
                    int    rowaffected  = cmd.ExecuteNonQuery();
                    string mail_subject = "";
                    string body         = "";
                    foreach (DataRow drow in dt.Rows)
                    {
                        if (drow[2].ToString() == "Rejected")
                        {
                            SendDatatoNAV objSendDatatoNAV = new SendDatatoNAV(drow[1].ToString());
                            mail_subject = "TMS : Request Rejected By Transporter - " + DateTime.Now.ToShortDateString();
                            body         = "Following requests are rejected ! ";
                        }
                        else
                        {
                            mail_subject = "TMS : Request Accepted By Transporter - " + DateTime.Now.ToShortDateString();
                            body         = "Following requests are accepted ! ";
                        }
                    }
                    // SendMailToCIPL(dtForMail, mail_subject, body);
                    transaction.Commit();
                    con.Close();
                    BindGridview("", "");
                    lblmsg.Text      = "Request successfully updated";
                    lblmsg.Visible   = true;
                    lblmsg.ForeColor = System.Drawing.Color.Green;
                }
                catch (Exception ex1)
                {
                    try
                    {
                        transaction.Rollback(); //manual
                        con.Close();
                        lblmsg.Text    = ex1.Message;
                        lblmsg.Visible = true;
                    }
                    catch (Exception ex2)
                    {
                        lblmsg.Text    = ex2.Message;
                        lblmsg.Visible = true;
                    }
                }
                #endregion
            }
        }
        else
        {
            lblmsg.ForeColor = System.Drawing.Color.Red;
            lblmsg.Text      = "Please select row(s) to submit";
            lblmsg.Visible   = true;
        }
    }
Пример #5
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            //string gateInDate = Convert.ToDateTime(date).ToString("yyyy-MM-dd") != "0001-01-01" ? Convert.ToDateTime(txtGateInDate.Text).ToString("yyyy-MM-dd") : "";
            string gateInDate = DateTime.Today.ToString("yyyy-MM-dd");
            if (gateInDate != "")
            {
                gateInDate = Convert.ToDateTime(gateInDate).ToString("yyyy-MM-dd h:mm tt");  // Convert.ToDateTime(gateInDate).ToString("yyyy-mm-dd hh:mm:ss.mmm");
            }
            else
            {
                lblmsg.Text    = " Please Enter Gate In Date";
                lblmsg.Visible = true;
                return;
            }
            if (ddlreqno.SelectedIndex != -1 && gateInDate != "" && txtGateInwardNo.Text != "" && lstHour.SelectedIndex != -1 && lstMin.SelectedIndex != -1 && (validatetruckNo(txtVehicle.Text.ToString()) == 1))
            {
                using (SqlConnection con = new SqlConnection())
                {
                    con.ConnectionString = BusinessLayerClasses.ConnectionString.GetConnectionString();
                    con.Open();
                    SqlCommand     cmd = new SqlCommand("TMS_sp_update_Request_operationalStatus");
                    SqlTransaction transaction;
                    transaction     = con.BeginTransaction(IsolationLevel.ReadUncommitted); // Start a local transaction.
                    cmd.Connection  = con;
                    cmd.Transaction = transaction;
                    #region Transaction
                    try
                    {
                        cmd.CommandTimeout = 0;
                        cmd.CommandType    = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@ReqNo", ddlreqno.SelectedItem.Text);
                        cmd.Parameters.AddWithValue("@GateInDate", gateInDate);
                        cmd.Parameters.AddWithValue("@BreweryGateInwardNo", txtGateInwardNo.Text);
                        cmd.Parameters.AddWithValue("@GateInTimeHH", lstHour.SelectedItem.Text);
                        cmd.Parameters.AddWithValue("@GateInTimeMM", lstMin.SelectedItem.Text);
                        cmd.Parameters.AddWithValue("@VehicleNo", txtVehicle.Text.Trim());
                        cmd.Parameters.AddWithValue("@TransporterType", lblTransporterType.Text);


                        cmd.ExecuteNonQuery();
                        // transaction.Commit();

                        SendDatatoNAV objSendDatatoNAV = new SendDatatoNAV(ddlreqno.SelectedItem.Text);
                        //ResetForm(); // Reset form
                        transaction.Commit();
                        con.Close();
                        ResetForm();
                        lblerr.Text    = "";
                        lblmsg.Text    = "Request Sent successfully";
                        lblmsg.Visible = true;
                    }
                    catch (Exception ex1)
                    {
                        try
                        {
                            transaction.Rollback(); //manual
                            ResetForm();            // Reset form
                            con.Close();
                            lblerr.Text    = ex1.Message;
                            lblerr.Visible = true;
                        }
                        catch (Exception ex2)
                        {
                            lblerr.Text    = ex2.Message;
                            lblerr.Visible = true;
                        }
                    }
                    #endregion
                }
            }
        }
        catch (Exception ee)
        {
            lblerr.Text    = "Please select a valid Date !! ";
            lblerr.Visible = true;
        }
        Bind_dropdownVehicle();
        ddlVehicle.SelectedIndex = 0;
        ddlreqno.Items.Clear();
        txtGateInwardNo.Text = "";
        txtVehicle.Text      = "";
    }
Пример #6
0
    private bool Update_LR_and_InvoiceStaging()
    {
        int  recordUpdated   = 0;
        bool isDataSendtoNav = false;
        bool result          = false;

        try
        {
            using (SqlConnection con = new SqlConnection())
            {
                con.ConnectionString = BusinessLayerClasses.ConnectionString.GetConnectionString();
                con.Open();
                SqlCommand     cmd = new SqlCommand("TMS_sp_Insert_InvoiceStaging");
                SqlTransaction transaction;
                transaction     = con.BeginTransaction(IsolationLevel.ReadUncommitted);
                cmd.Connection  = con;
                cmd.Transaction = transaction;
                #region Transaction
                try
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandType    = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@LRNo_", lblLRNo.Text.Trim());
                    if (ddlSpecialDiscount.SelectedItem.Value == "0")
                    {
                        cmd.Parameters.AddWithValue("@Payment_Discount_Scheme_Code", "");
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@Payment_Discount_Scheme_Code", ddlSpecialDiscount.SelectedItem.Text);
                    }
                    if (ddlDelayPenalty.SelectedItem.Value == "0")
                    {
                        cmd.Parameters.AddWithValue("@Penalty_Reason_Code", "");
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@Penalty_Reason_Code", ddlDelayPenalty.SelectedItem.Text);
                    }


                    cmd.Parameters.AddWithValue("@TransporterRemarks", txttransporterRemark.Text);
                    cmd.Parameters.AddWithValue("@BillProcessingTeamRemark", txtBillProcessTeamRemarks.Text);

                    recordUpdated = cmd.ExecuteNonQuery(); //saved in database

                    if (recordUpdated > 0)
                    {
                        //Bind_gridInvoice(ViewState["LRNo"].ToString());
                        //BindLRHeader(ViewState["LRNo"].ToString());

                        SendDatatoNAV objsenddatatonav = new SendDatatoNAV();
                        isDataSendtoNav = objsenddatatonav.SendInvoiceDatatoNav(lblLRNo.Text.Trim()); //send invoice
                    }
                    else
                    {
                        lblerr.Text    = "Entries cannot be submitted at this time, Please contact adminstrator ";
                        lblerr.Visible = true;
                    }
                }
                catch (Exception ex1)
                {
                    transaction.Rollback();                                                                                                                                                                                 //manual
                    Int32 changeBackApprovalstatus         = GetSQLData("Update TMS_LR_Header Set [Approval Status] ='Pending for Invoice' where [LR No_] = '" + ViewState["LRNo"].ToString() + "'");                       // lmaru8748
                    Int32 ChangeBacktoFreightInvoiceStatus = GetSQLData(" UPDATE tms_Portal_Freight_Invoice Set [Approval_Status_Invoice] ='Pending for Invoice' where [LR No_] = '" + ViewState["LRNo"].ToString() + "'"); // lmaru8748
                    con.Close();
                    lblerr.Text      = ex1.Message;
                    lblerr.ForeColor = System.Drawing.Color.Red;
                    lblerr.Visible   = true;
                }
                #endregion

                #region Commit Transaction
                if (recordUpdated > 0 && isDataSendtoNav == true)
                {
                    transaction.Commit();
                    con.Close();
                    lblerr.Text      = "Entries updated and submitted at Nav system successfully";
                    lblerr.ForeColor = System.Drawing.Color.Green;
                    lblerr.Visible   = true;
                    result           = true;
                }
                else
                {
                    transaction.Rollback();
                    Int32 changeBackApprovalstatus         = GetSQLData("Update TMS_LR_Header Set [Approval Status] ='Pending for Invoice' where [LR No_] = '" + ViewState["LRNo"].ToString() + "'");
                    Int32 ChangeBacktoFreightInvoiceStatus = GetSQLData(" UPDATE tms_Portal_Freight_Invoice Set [Approval_Status_Invoice] ='Pending for Invoice' where [LR No_] = '" + ViewState["LRNo"].ToString() + "'");
                    con.Close();
                    if (!isDataSendtoNav)
                    {
                        lblerr.Text = "The Invoice Stagging Table entry already exists in Nav System, Cannot be post twice.";
                    }
                    else
                    {
                        lblerr.Text = "Entries Cannot be submitted at this moment, Please contact administrator !  ";
                    }
                    lblerr.ForeColor = System.Drawing.Color.Red;
                    lblerr.Visible   = true;
                }
                #endregion
            }
        }
        catch (Exception ed)
        {
        }
        return(result);
    }