public string SaveVendor(Vendor vendor, Merchant merchant)
    {
        string ret = "";

        vendor.User = HttpContext.Current.Session["UserName"].ToString();
        string passwd = bll.GetPasswordString();

        vendor.Passwd  = bll.EncryptString(passwd);
        vendor.Status  = bll.DecryptString(datafile.GetSystemParameter(3, 2));
        vendor.Subject = bll.DecryptString(datafile.GetSystemParameter(3, 1));
        vendor.Message = bll.DecryptString(datafile.GetSystemParameter(3, 3));
        datafile.SaveVendorDetails(vendor, merchant);
        if (vendor.Vendorid.Equals(0))
        {
            /// Now Notify the Person of the Vendor.
            string message = "Hello " + vendor.Contract + "\n. Your " + vendor.Status + " Vendor Credentials for the PegPay Payments Platform are" + Environment.NewLine + Environment.NewLine + "\n";
            message += " Vendor Code: " + vendor.VendorCode + Environment.NewLine + Environment.NewLine + "\n";
            message += ", Password: "******"\n . The Url for the " + vendor.Status + " PegPay Payments Platform is: " + vendor.Message;
            string mailto  = vendor.Email;
            string subject = vendor.Subject + " - " + vendor.Status;
            string name    = vendor.Contract;
            string res     = mailer.GoogleMail(mailto, subject, message, name);
            if (res.Equals("SENT"))
            {
                ret = "Vendor Created Successfully [" + vendor.VendorCode + " - " + passwd + "]";
            }
            else
            {
                ret = "Vendor " + vendor.VendorName + " created successfully, Email failed :(" + ret + ")";
            }
        }
        else
        {
            if (vendor.Sendemail)
            {
                dTable = datafile.GetVendorById(vendor);
                if (dTable.Rows.Count > 0)
                {
                    string spasswd = dTable.Rows[0]["VendorPassword"].ToString();
                    passwd = bll.DecryptString(spasswd);
                    string message = "Hello " + vendor.Contract + "," + Environment.NewLine + Environment.NewLine + "\n";
                    message += "Your " + vendor.Status + " Vendor Credentials are" + Environment.NewLine + Environment.NewLine + "\n";
                    message += " Vendor Code: " + vendor.VendorCode + Environment.NewLine + Environment.NewLine + "\n";
                    message += ", Password: "******"\n . The Url for the " + vendor.Status + " PegPay Payments Platform is: " + vendor.Message;
                    string mailto  = vendor.Email;
                    string subject = vendor.Subject + " - " + vendor.Status;
                    string name    = vendor.Contract;
                    string res     = mailer.GoogleMail(mailto, subject, message, name);
                    if (res.Equals("SENT"))
                    {
                        ret = vendor.VendorName + " Vendor Details Updated and Email Resent Successfully";
                    }
                    else
                    {
                        ret = vendor.VendorName + " Vendor Details Updated but Email Resending failed (" + res + ")";
                    }
                }
            }
            else if (vendor.Reset)
            {
                datafile.ResetVendorPassword(vendor);
                SystemUser user = new SystemUser();
                user.Uname  = HttpContext.Current.Session["Username"].ToString();
                user.Action = "Vendor Password Reset [" + vendor.VendorCode + "]";
                LogActivity(user);
                string message = "Hello " + vendor.Contract + "," + Environment.NewLine + Environment.NewLine + "\n";
                message += "Your " + vendor.Status + " Vendor Credentials have been reset" + Environment.NewLine + Environment.NewLine + "\n";
                message += " Vendor Code: " + vendor.VendorCode + Environment.NewLine + Environment.NewLine + "\n";
                message += ", Password: "******"\r\n . The Url for the " + vendor.Status + " PegPay Payments Platform is: " + vendor.Message;
                string mailto  = vendor.Email;
                string subject = vendor.Subject + " - " + vendor.Status;
                string name    = vendor.Contract;
                string res     = mailer.GoogleMail(mailto, subject, message, name);
                if (res.Equals("SENT"))
                {
                    ret = vendor.VendorName + " Vendor Details Updated and Email Resent Successfully";
                }
                else
                {
                    ret = vendor.VendorName + " Vendor Details Updated but Email Resend faile(" + res + ")";
                }
            }
            else
            {
                ret = vendor.VendorName + " Vendor Details Updated Successfully";
            }
        }
        return(ret);
    }