コード例 #1
0
    private bool SendEmailInvitation(AuctionDetails auctiondetails, ArrayList recipients, ref int failedcount, ref int successcount)
    {
        bool   success = false;
        string subject = "Trans-Asia / Commnunications : Invitation to Auction";

        failedcount  = 0;
        successcount = 0;

        try
        {
            for (int i = 0; i < recipients.Count; i++)
            {
                AuctionParticipant p = (AuctionParticipant)recipients[i];

                if (!MailHelper.SendEmail(MailTemplate.GetDefaultSMTPServer(),
                                          MailHelper.ChangeToFriendlyName(auctiondetails.Creator, auctiondetails.CreatorEmail),
                                          MailHelper.ChangeToFriendlyName(p.Name, p.EmailAddress),
                                          subject,
                                          CreateInvitationBody(auctiondetails, p),
                                          MailTemplate.GetTemplateLinkedResources(this)))
                {                       // if sending failed
                    failedcount++;
                    LogHelper.EventLogHelper.Log("Auction > Send Invitation : Sending Failed to " + p.EmailAddress, System.Diagnostics.EventLogEntryType.Error);
                }
                else
                {                       // if sending successful
                    successcount++;
                    LogHelper.EventLogHelper.Log("Auction > Send Invitation : Email Sent to " + p.EmailAddress, System.Diagnostics.EventLogEntryType.Information);
                    // update sent mail count
                    SqlHelper.ExecuteNonQuery(connstring, "sp_SendEmailInvitation", new SqlParameter[] { new SqlParameter("@ParticipantId", p.ID) });
                }
            }

            success = true;
        }
        catch (Exception ex)
        {
            success = false;
            LogHelper.EventLogHelper.Log("Auction > Send Invitation : " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
        }

        try
        {
            for (int j = 0; j < recipients.Count; j++)
            {
                AuctionParticipant p = (AuctionParticipant)recipients[j];

                if (SMSHelper.AreValidMobileNumbers(p.MobileNo.Trim()))
                {
                    SMSHelper.SendSMS(new SMSMessage(CreateSMSInvitationBody(auctiondetails, p).Trim(), p.MobileNo.Trim())).ToString();
                }
            }
        }
        catch (Exception ex)
        {
            LogHelper.EventLogHelper.Log("Auction > Send SMS Invitation : " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
        }

        return(success);
    }
コード例 #2
0
    private bool SendEmailInvitation(BidDetails biddetails, ArrayList recipients, ref int failedcount, ref int successcount)
    {
        bool   success = false;
        string subject = "Trans-Asia  Incorporated/ Commnunications : Invitation to Bid";

        failedcount  = 0;
        successcount = 0;

        try
        {
            for (int i = 0; i < recipients.Count; i++)
            {
                BidParticipant p = (BidParticipant)recipients[i];

                if (!MailHelper.SendEmail(MailTemplate.GetDefaultSMTPServer(),
                                          MailHelper.ChangeToFriendlyName(biddetails.Creator, biddetails.CreatorEmail),
                                          MailHelper.ChangeToFriendlyName(p.Name, p.EmailAddress),
                                          subject,
                                          CreateInvitationBody(biddetails, p),
                                          MailTemplate.GetTemplateLinkedResources(this)))
                {       // if sending failed
                    failedcount++;
                    LogHelper.EventLogHelper.Log("Bid Event > Send Invitation : Sending Failed to " + p.EmailAddress, System.Diagnostics.EventLogEntryType.Error);
                }
                else
                {       // if sending successful
                    successcount++;
                    LogHelper.EventLogHelper.Log("Bid Event > Send Invitation : Email Sent to " + p.EmailAddress, System.Diagnostics.EventLogEntryType.Information);

                    //add 1 to emailsent field based on vendorID and BidRefNo
                    SqlParameter[] sqlparams = new SqlParameter[2];
                    sqlparams[0]       = new SqlParameter("@Vendorid", SqlDbType.Int);
                    sqlparams[0].Value = p.ID;
                    sqlparams[1]       = new SqlParameter("@BidRefNo", SqlDbType.VarChar);
                    sqlparams[1].Value = Int32.Parse(Session["BidRefNo"].ToString());
                    SqlHelper.ExecuteNonQuery(connstring, CommandType.StoredProcedure, "sp_BidInvitationAddEmailSent", sqlparams);
                }
            }

            success = true;
        }
        catch (Exception ex)
        {
            success = false;
            LogHelper.EventLogHelper.Log("Bid Event > Send Invitation : " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
        }

        try
        {
            for (int j = 0; j < recipients.Count; j++)
            {
                BidParticipant p = (BidParticipant)recipients[j];

                if (SMSHelper.AreValidMobileNumbers(p.MobileNo.Trim()))
                {
                    SMSHelper.SendSMS(new SMSMessage(CreateInvitationSmsBody(biddetails, p).Trim(), p.MobileNo.Trim())).ToString();
                }
            }
        }

        catch (Exception ex)
        {
            LogHelper.EventLogHelper.Log("Bid Event > Send SMS Invitation : " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
        }

        return(success);
    }
コード例 #3
0
    protected void gvBidItemDetails_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "withdraw":
        {
            GridViewRow row            = ((Control)e.CommandSource).NamingContainer as GridViewRow;
            Panel       tmp_pnlcommand = (Panel)row.FindControl("pnlLinks");
            Panel       tmp_pnlcomment = (Panel)row.FindControl("pnlComments");

            tmp_pnlcommand.Visible = false;
            tmp_pnlcomment.Visible = true;
        } break;

        case "continuewithdraw":
        {
            if (BidItemTransaction.WithdrawBidItem(connstring, int.Parse(e.CommandArgument.ToString()), Constant.BIDITEM_STATUS.WITHDRAWAL_STATUS.WITHDRAWNED))
            {
                GridViewRow row            = ((Control)e.CommandSource).NamingContainer as GridViewRow;
                TextBox     tmp_txtComment = (TextBox)row.FindControl("txtComment");
                CheckBox    tmp_chkBox     = (CheckBox)row.FindControl("chkAlowVendorView");

                InsertWithdrawnedItemComments(int.Parse(e.CommandArgument.ToString()), tmp_txtComment.Text.ToString().Trim(), Session[Constant.SESSION_USERID].ToString(), tmp_chkBox.Checked);
                GetAllVendorsInfoByBidRef(int.Parse(e.CommandArgument.ToString()));
                SendEmailToVendors();

                #region Dev Richard - Send SMS Notification

                ArrayList recipients = GetSelectedSuppliers();

                GridViewRow lblItemRow = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
                Label       lblItem    = (Label)gvBidItemDetails.Rows[row.RowIndex].FindControl("lblItem");

                for (int a = 0; a < recipients.Count; a++)
                {
                    BidParticipant p        = (BidParticipant)recipients[a];
                    String         mobileNo = p.MobileNo;

                    if (SMSHelper.AreValidMobileNumbers(mobileNo.Trim()))
                    {
                        String textMessage = "“We wish to inform you that '" + lblItem.Text + "' has been withdrawn. Kindly go to your portal account under Withdrawn bid Items for details.”";

                        try
                        {
                            SMSHelper.SendSMS(new SMSMessage(textMessage, mobileNo));
                        }
                        catch
                        { }
                    }
                }

                #endregion

                Response.Redirect("withdrawnedbiditems.aspx");
            }
        } break;

        case "cancelwithdraw":
        {
            GridViewRow row            = ((Control)e.CommandSource).NamingContainer as GridViewRow;
            Panel       tmp_pnlcommand = (Panel)row.FindControl("pnlLinks");
            Panel       tmp_pnlcomment = (Panel)row.FindControl("pnlComments");
            TextBox     tmp_txtComment = (TextBox)row.FindControl("txtComment");

            tmp_pnlcommand.Visible = true;
            tmp_pnlcomment.Visible = false;
            tmp_txtComment.Text    = "";
        } break;
        }
    }
コード例 #4
0
    private bool SendEmail_ChangeDeadline(BidDetails biddetails, ArrayList recipients)
    {
        //String b_Company = ((Label)((DetailsView)Biddetails_details1.FindControl("dvEventDetails")).Rows[5].Cells[1].FindControl("lblCompany")).Text;

        bool   success      = false;
        string subject      = "Trans-Asia / Commnunications : Changed Submission Deadline Notification";
        int    failedcount  = 0;
        int    successcount = 0;

        try
        {
            #region NOTIFY VENDORS

            for (int i = 0; i < recipients.Count; i++)
            {
                BidParticipant p = (BidParticipant)recipients[i];

                if (!MailHelper.SendEmail(MailTemplate.GetDefaultSMTPServer(),
                                          MailHelper.ChangeToFriendlyName(Session[Constant.SESSION_USERFULLNAME].ToString(), Session[Constant.SESSION_USEREMAIL].ToString()),
                                          MailHelper.ChangeToFriendlyName(p.Name, p.EmailAddress),
                                          subject,
                                          CreateNotificationBody(biddetails, p),
                                          MailTemplate.GetTemplateLinkedResources(this)))
                {       // if sending failed
                    failedcount++;
                    LogHelper.EventLogHelper.Log("Bids > Send Notification : Sending Failed to " + p.EmailAddress, System.Diagnostics.EventLogEntryType.Error);
                }
                else
                {       // if sending successful
                    successcount++;
                    LogHelper.EventLogHelper.Log("Bids > Send Notification : Email Sent to " + p.EmailAddress, System.Diagnostics.EventLogEntryType.Information);

                    #region add 1 to emailsent field based on vendorID and BidRefNo

                    //SqlParameter[] sqlparams = new SqlParameter[2];
                    //sqlparams[0] = new SqlParameter("@Vendorid", SqlDbType.Int);
                    //sqlparams[0].Value = p.ID;
                    //sqlparams[1] = new SqlParameter("@BidRefNo", SqlDbType.VarChar);
                    //sqlparams[1].Value = Int32.Parse(Session["BidRefNo"].ToString());
                    //SqlHelper.ExecuteNonQuery(connstring, CommandType.StoredProcedure, "sp_BidInvitationAddEmailSent", sqlparams);
                    #endregion
                }
            }

            #region SMS SENDER
            try
            {
                for (int j = 0; j < recipients.Count; j++)
                {
                    BidParticipant BP = (BidParticipant)recipients[j];

                    if (SMSHelper.AreValidMobileNumbers(BP.MobileNo.Trim()))
                    {
                        SMSHelper.SendSMS(new SMSMessage(CreateInvitationSmsBody(biddetails, BP).Trim(), BP.MobileNo.Trim())).ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.EventLogHelper.Log("Bid Event > Send SMS Invitation : " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
            }
            #endregion

            #endregion

            #region NOTIFY BUYER

            if (!MailHelper.SendEmail(MailTemplate.GetDefaultSMTPServer(),
                                      MailHelper.ChangeToFriendlyName(Session[Constant.SESSION_USERFULLNAME].ToString(), Session[Constant.SESSION_USEREMAIL].ToString()),
                                      MailHelper.ChangeToFriendlyName(biddetails.Creator, biddetails.CreatorEmail),
                                      subject,
                                      CreateNotificationBody(biddetails),
                                      MailTemplate.GetTemplateLinkedResources(this)))
            {
                failedcount++;
                LogHelper.EventLogHelper.Log("Bids > Send Notification : Sending Failed to " + Session[Constant.SESSION_USEREMAIL].ToString(), System.Diagnostics.EventLogEntryType.Error);
            }
            else
            {
                successcount++;
                LogHelper.EventLogHelper.Log("Bids > Send Notification : Email Sent to " + Session[Constant.SESSION_USEREMAIL].ToString(), System.Diagnostics.EventLogEntryType.Information);
            }

            #endregion

            success = true;
        }
        catch (Exception ex)
        {
            success = false;
            LogHelper.EventLogHelper.Log("Bid Item > Send ??? Change Notice : " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
        }

        return(success);
    }
コード例 #5
0
    protected void gvTenders_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridViewRow row = ((Control)e.CommandSource).NamingContainer as GridViewRow;

        Panel       tmp_pnlcommand = (Panel)row.FindControl("pnlCommands");
        Panel       tmp_pnlcomment = (Panel)row.FindControl("pnlComments");
        LinkButton  btnaward       = (LinkButton)row.FindControl("btnOkAward");
        LinkButton  btnrenegotiate = (LinkButton)row.FindControl("btnOkRenegotiate");
        HiddenField hdnVendorID    = (HiddenField)row.FindControl("hdnVendorID");


        //HiddenField VendorID = (HiddenField)gvTenders.FindControl("hdnVendorId");

        switch (e.CommandName)
        {
        case "AwardItem":
        {
            /* old code
             * int awardstatus = Constant.BIDTENDER_STATUS.STATUS.AWARDED;
             * int notawardedstatus = Constant.BIDTENDER_STATUS.STATUS.NOT_AWARDED;
             *
             * string vendorname = GetVendorInfo(int.Parse(e.CommandArgument.ToString()), "name");
             * string vendoremail = GetVendorInfo(int.Parse(e.CommandArgument.ToString()), "email");
             *
             * ChangeStatus(int.Parse(e.CommandArgument.ToString()), awardstatus);
             *
             * SendEmail(vendorname, vendoremail, awardstatus, "Trans-Asia / Commnunications : Congratulations");
             *
             *
             * try
             * {
             *  if (SMSHelper.AreValidMobileNumbers(GetVendorMobileNo(int.Parse(hdnVendorID.Value))))
             *  {
             *      SMSHelper.SendSMS(new SMSMessage(CreateSmsBody(e.CommandArgument.ToString().Trim()), GetVendorMobileNo(int.Parse(hdnVendorID.Value))));
             *  }
             * }
             * catch (Exception ex)
             * {
             *  LogHelper.EventLogHelper.Log("Bid Event > Send SMS Notification : " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
             * }
             *
             * //GridViewRow row = ((Control)e.CommandSource).NamingContainer as GridViewRow;
             * TextBox tmp_txtComment = (TextBox)row.FindControl("txtComment");
             * InsertNewComment(tmp_txtComment.Text, int.Parse(e.CommandArgument.ToString()));
             *
             * GetVendorsInfoNotAwardedOrConverted(int.Parse(dvEventDetails.Rows[0].Cells[1].Text.ToString()));
             * UpdateStatus(notawardedstatus);
             *
             * GetVendorsInfoNotAwardedOrConvertedByBidRef(int.Parse(((HiddenField)dvEventDetails.Rows[5].Cells[1].FindControl("hdn_bidrefno")).Value.ToString()), int.Parse(dvEventDetails.Rows[0].Cells[1].Text.ToString()));
             * //SendEmailToNotAwardedOrConverted(notawardedstatus);
             * //gvTenders.DataBind();
             * Response.Redirect("awardedbiditems.aspx");
             */

            //-- by: zander (2009-03-24
            int awardstatus      = Constant.BIDTENDER_STATUS.STATUS.AWARDED;
            int notawardedstatus = Constant.BIDTENDER_STATUS.STATUS.NOT_AWARDED;
            int bidrefno         = int.Parse(((HiddenField)dvEventDetails.Rows[5].Cells[1].FindControl("hdn_bidrefno")).Value.ToString());

            string vendorname  = GetVendorInfo(int.Parse(e.CommandArgument.ToString()), "name");
            string vendoremail = GetVendorInfo(int.Parse(e.CommandArgument.ToString()), "email");

            ChangeStatus(int.Parse(e.CommandArgument.ToString()), awardstatus);

            try
            {
                if (SMSHelper.AreValidMobileNumbers(GetVendorMobileNo(int.Parse(hdnVendorID.Value))))
                {
                    SMSHelper.SendSMS(new SMSMessage(CreateSmsBody(e.CommandArgument.ToString().Trim()), GetVendorMobileNo(int.Parse(hdnVendorID.Value))));
                }
            }
            catch (Exception ex)
            {
                LogHelper.EventLogHelper.Log("Bid Event > Send SMS Notification : " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
            }

            TextBox tmp_txtComment = (TextBox)row.FindControl("txtComment");
            InsertNewComment(tmp_txtComment.Text, int.Parse(e.CommandArgument.ToString()));

            // -- this is for automating decline of not awarded vendors
            //GetVendorsInfoNotAwardedOrConverted(int.Parse(dvEventDetails.Rows[0].Cells[1].Text.ToString()));
            //UpdateStatus(notawardedstatus);


            SendAwardedEmailNotification(bidrefno);

            // -- by: jason sia 2010 11 08
            Response.Redirect("endorsementsummary.aspx");

            //Response.Redirect("awardedbiditems.aspx");
            //-- by: zander (2009-03-24
        } break;

        case "RenegotiateItem":
        {
            int renegotiatestatus = Constant.BIDTENDER_STATUS.STATUS.RENEGOTIATED;
            int purchasingtobuyer = Constant.BIDTENDER_STATUS.RENEGOTIATION_STATUS.PURCHASING_TO_BUYER;

            string vendorname  = GetVendorInfo(int.Parse(e.CommandArgument.ToString()), "name");
            string vendoremail = GetVendorInfo(int.Parse(e.CommandArgument.ToString()), "email");

            ChangeStatus(int.Parse(e.CommandArgument.ToString()), renegotiatestatus);
            ChangeRenegotiationStatus(int.Parse(e.CommandArgument.ToString()), purchasingtobuyer);

            SendEmail(vendorname, vendoremail, renegotiatestatus, "Trans-Asia / Commnunications : For Clarification");
            //GridViewRow row = ((Control)e.CommandSource).NamingContainer as GridViewRow;
            TextBox tmp_txtComment = (TextBox)row.FindControl("txtComment");
            InsertNewComment(tmp_txtComment.Text, int.Parse(e.CommandArgument.ToString()));
            //gvTenders.DataBind();
            Response.Redirect("bidsforrenegotiation.aspx");
        } break;

        case "SetComments":
        {
            //GridViewRow row = ((Control)e.CommandSource).NamingContainer as GridViewRow;

            //Panel tmp_pnlcommand = (Panel)row.FindControl("pnlCommands");
            //Panel tmp_pnlcomment = (Panel)row.FindControl("pnlComments");
            //LinkButton btnaward = (LinkButton)row.FindControl("btnOkAward");
            //LinkButton btnrenegotiate = (LinkButton)row.FindControl("btnOkRenegotiate");
            //HiddenField hdnVendorID = (HiddenField)row.FindControl("hdnVendorID");

            tmp_pnlcommand.Visible = false;
            tmp_pnlcomment.Visible = true;

            switch (e.CommandArgument.ToString().ToUpper())
            {
            case "AWARD":
                btnaward.Visible       = true;
                btnrenegotiate.Visible = false;
                break;

            case "RENEGOTIATE":
                btnaward.Visible       = false;
                btnrenegotiate.Visible = true;
                break;
            }
        } break;

        case "CancelComments":
        {
            //GridViewRow row = ((Control)e.CommandSource).NamingContainer as GridViewRow;
            //Panel tmp_pnlcommand = (Panel)row.FindControl("pnlCommands");
            //Panel tmp_pnlcomment = (Panel)row.FindControl("pnlComments");
            TextBox tmp_txtComment = (TextBox)row.FindControl("txtComment");

            tmp_pnlcommand.Visible = true;
            tmp_pnlcomment.Visible = false;
            tmp_txtComment.Text    = "";
        } break;

        case "Select":
        {
            string[] args = e.CommandArgument.ToString().Split(new char[] { '|' });
            Session[Constant.SESSION_BIDTENDERNO] = args[0];
            Session["TVendorId"] = args[1];
            Session[Constant.SESSION_BIDREFNO] = args[2];
            Session["ViewOption"] = "AsBuyer";
            pnlDetails.Visible    = true;
            //Session[Constant.SESSION_BIDTENDERNO] = e.CommandArgument.ToString();
            BindComments();
        } break;
        }
    }
コード例 #6
0
    protected void gvBidItemTenders_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridViewRow gvr            = ((Control)e.CommandSource).NamingContainer as GridViewRow;
        Panel       pnlLinks       = (Panel)gvr.FindControl("pnlLinks");
        Panel       pnlComments    = (Panel)gvr.FindControl("pnlComments");
        LinkButton  lnkOK          = (LinkButton)gvr.FindControl("lnkOK");
        LinkButton  lnkReendorsed  = (LinkButton)gvr.FindControl("lnkEndorse");
        LinkButton  lnkRenegotiate = (LinkButton)gvr.FindControl("lnkRenegotiate");
        HiddenField hdnVendorId    = (HiddenField)gvr.FindControl("hdnVendorId");

        switch (e.CommandName)
        {
        case "Clarify":
        {
            pnlLinks.Visible    = false;
            pnlComments.Visible = true;
            gvBidItemTenders.Columns[5].ControlStyle.Width = Unit.Pixel(150);
            ViewState["Command"] = "clarify";
            lnkOK.Attributes.Add("onclick", "return confirm('Are you sure you want to clarify this item?');");
            pnlFileUpload.Visible = true;
        } break;

        case "Renegotiate":
        {
            pnlLinks.Visible    = false;
            pnlComments.Visible = true;
            gvBidItemTenders.Columns[5].ControlStyle.Width = Unit.Pixel(150);
            ViewState["Command"] = "renegotiate";
            lnkOK.Attributes.Add("onclick", "return confirm('Are you sure you want to renegotiate this item?');");
            pnlFileUpload.Visible = true;
        } break;

        case "Re-endorse":
        {
            pnlLinks.Visible    = false;
            pnlComments.Visible = true;
            gvBidItemTenders.Columns[5].ControlStyle.Width = Unit.Pixel(150);
            ViewState["Command"] = "re-endorse";
            lnkOK.Attributes.Add("onclick", "return confirm('Are you sure you want to re-endorse this item?');");
        } break;

        case "ContinueEndorsement":
        {
            if (ViewState["Command"] != null)
            {
                TextBox tbComments = (TextBox)pnlComments.FindControl("txtComment");

                // save comment
                if (ViewState["Command"].ToString() == "clarify")
                {
                    // update bid tender status to "renegotiated"
                    bool updateOk  = BidTransaction.UpdateBidTenderStatus(connstring, Convert.ToInt32(e.CommandArgument.ToString()), Constant.BIDTENDER_STATUS.STATUS.RENEGOTIATED);
                    bool updateOk2 = BidTransaction.UpdateBidTenderRenegotiationStatus(connstring, Convert.ToInt32(e.CommandArgument.ToString()), Constant.BIDTENDER_STATUS.RENEGOTIATION_STATUS.BUYER_TO_VENDOR);
                    bool updateOk3 = BidTransaction.UpdateAsClarifiedStatus(connstring, Convert.ToInt32(e.CommandArgument.ToString()), 1);

                    bool saveCommentOk = BidTransaction.SaveBidTenderComment(connstring, int.Parse(e.CommandArgument.ToString()),
                                                                             int.Parse(Session[Constant.SESSION_USERID].ToString()), tbComments.Text.Trim(), Constant.BIDTENDERCOMMENT_BUYER_TO_VENDOR);

                    if (updateOk && updateOk2 && updateOk3 && saveCommentOk)
                    {
                        //save attachments
                        DeleteExistingBidEventAttachments(int.Parse(Session[Constant.SESSION_BIDREFNO].ToString()));
                        SaveBidEventAttachments(int.Parse(Session[Constant.SESSION_BIDREFNO].ToString()));
                        Session["Message"] = "Bid item was successfully clarified.";

                        //send sms
                        try
                        {
                            if (SMSHelper.AreValidMobileNumbers(GetVendorMobileNo(int.Parse(hdnVendorId.Value))))
                            {
                                SMSHelper.SendSMS(new SMSMessage(CreateSmsBody(e.CommandArgument.ToString().Trim()), GetVendorMobileNo(int.Parse(hdnVendorId.Value))));
                            }
                        }
                        catch (Exception ex)
                        {
                            LogHelper.EventLogHelper.Log("Bid Event > Send SMS Notification : " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
                        }
                        //end of sms sending

                        Response.Redirect("renegotiatedbiditemdetails.aspx");
                    }
                    else
                    {
                        Session["Message"] = "Bid item was not clarified.";
                        pnlLinks.Visible   = true;
                    }
                }
                else if (ViewState["Command"].ToString() == "renegotiate")
                {
                    // update bid tender status to "renegotiated"
                    bool updateOk  = BidTransaction.UpdateBidTenderStatus(connstring, Convert.ToInt32(e.CommandArgument.ToString()), Constant.BIDTENDER_STATUS.STATUS.RENEGOTIATED);
                    bool updateOk2 = BidTransaction.UpdateBidTenderRenegotiationStatus(connstring, Convert.ToInt32(e.CommandArgument.ToString()), Constant.BIDTENDER_STATUS.RENEGOTIATION_STATUS.BUYER_TO_VENDOR);
                    bool updateOk3 = BidTransaction.UpdateAsClarifiedStatus(connstring, Convert.ToInt32(e.CommandArgument.ToString()), 0);

                    bool saveCommentOk = BidTransaction.SaveBidTenderComment(connstring, int.Parse(e.CommandArgument.ToString()),
                                                                             int.Parse(Session[Constant.SESSION_USERID].ToString()), tbComments.Text.Trim(), Constant.BIDTENDERCOMMENT_BUYER_TO_VENDOR);

                    if (updateOk && updateOk2 && updateOk3 && saveCommentOk)
                    {
                        //save attachments
                        DeleteExistingBidEventAttachments(int.Parse(Session[Constant.SESSION_BIDREFNO].ToString()));
                        SaveBidEventAttachments(int.Parse(Session[Constant.SESSION_BIDREFNO].ToString()));
                        Session["Message"] = "Bid item was successfully clarified.";

                        //send sms
                        try
                        {
                            if (SMSHelper.AreValidMobileNumbers(GetVendorMobileNo(int.Parse(hdnVendorId.Value))))
                            {
                                SMSHelper.SendSMS(new SMSMessage(CreateSmsBody(e.CommandArgument.ToString().Trim()), GetVendorMobileNo(int.Parse(hdnVendorId.Value))));
                            }
                        }
                        catch (Exception ex)
                        {
                            LogHelper.EventLogHelper.Log("Bid Event > Send SMS Notification : " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
                        }
                        //end of sms sending
                        Response.Redirect("renegotiatedbiditemdetails.aspx");
                    }
                    else
                    {
                        Session["Message"] = "Bid item was not clarified.";
                        pnlLinks.Visible   = true;
                    }
                }
                else if (ViewState["Command"].ToString() == "re-endorse")
                {
                    // update bid tender status to "endorsed"
                    bool updateOk  = BidTransaction.UpdateBidTenderStatus(connstring, Convert.ToInt32(e.CommandArgument.ToString()), Constant.BIDTENDER_STATUS.STATUS.ENDORSED);
                    bool updateOk2 = BidTransaction.UpdateBidTenderRenegotiationStatus(connstring, Convert.ToInt32(e.CommandArgument.ToString()), Constant.BIDTENDER_STATUS.RENEGOTIATION_STATUS.BUYER_TO_PURCHASING);

                    bool saveCommentOk = BidTransaction.SaveBidTenderComment(connstring, int.Parse(e.CommandArgument.ToString()),
                                                                             int.Parse(Session[Constant.SESSION_USERID].ToString()), tbComments.Text.Trim(), Constant.BIDTENDERCOMMENT_BUYER_TO_PURCHASING);

                    if (updateOk && updateOk2 && saveCommentOk)
                    {
                        Session["Message"] = "Bid item was successfully endorsed.";
                        Response.Redirect("renegotiatedbiditemdetails.aspx");
                    }
                    else
                    {
                        Session["Message"]  = "Bid item was not endorsed.";
                        pnlLinks.Visible    = true;
                        pnlComments.Visible = false;
                    }
                }
            }
        } break;

        case "CancelEndorsement":
        {
            pnlLinks.Visible                      = true;
            pnlComments.Visible                   = false;
            dvTenderDetails.PageIndex             = gvBidItemTenders.SelectedIndex;
            Session[Constant.SESSION_BIDTENDERNO] = gvBidItemTenders.DataKeys[gvBidItemTenders.SelectedIndex].Values[0].ToString();
            BindComments();
            gvBidItemTenders.Columns[5].ControlStyle.Width = Unit.Pixel(90);
            pnlFileUpload.Visible = false;
        } break;

        case "Select":
        {
            string[] args = e.CommandArgument.ToString().Split(new char[] { '|' });
            Session[Constant.SESSION_BIDTENDERNO] = args[0];
            Session["TVendorId"] = args[1];
            Session[Constant.SESSION_BIDREFNO] = args[2];
            Session["ViewOption"] = "AsBuyer";
            lblCurrentIndex.Text  = "0";
            BindComments();
            gvBidItemTenders.Columns[5].ControlStyle.Width = Unit.Pixel(90);
            dvTenderDetails.Visible      = true;
            pnlTenderAttachments.Visible = true;
        } break;
        }
    }