/// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update button is clicked.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/17/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnUpdateClick(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    int portalID;
                    if (Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                    {
                        portalID = -1;
                    }
                    else
                    {
                        portalID = PortalId;
                    }
                    var objVendors = new VendorController();
                    var objVendor  = new VendorInfo
                    {
                        PortalId   = portalID,
                        VendorId   = VendorID,
                        VendorName = txtVendorName.Text,
                        Unit       = addresssVendor.Unit,
                        Street     = addresssVendor.Street,
                        City       = addresssVendor.City,
                        Region     = addresssVendor.Region,
                        Country    = addresssVendor.Country,
                        PostalCode = addresssVendor.Postal,
                        Telephone  = addresssVendor.Telephone,
                        Fax        = addresssVendor.Fax,
                        Cell       = addresssVendor.Cell,
                        Email      = txtEmail.Text,
                        Website    = txtWebsite.Text,
                        FirstName  = txtFirstName.Text,
                        LastName   = txtLastName.Text,
                        UserName   = UserInfo.UserID.ToString(),
                        LogoFile   = ctlLogo.Url,
                        KeyWords   = txtKeyWords.Text,
                        Authorized = chkAuthorized.Checked
                    };
                    if (VendorID == -1)
                    {
                        try
                        {
                            VendorID = objVendors.AddVendor(objVendor);
                        }
                        catch
                        {
                            AddModuleMessage("ErrorAddVendor", ModuleMessage.ModuleMessageType.RedError);
                            return;
                        }
                    }
                    else
                    {
                        VendorInfo vendorCheck = objVendors.GetVendor(VendorID, portalID);
                        if (vendorCheck != null)
                        {
                            objVendors.UpdateVendor(objVendor);
                        }
                        else
                        {
                            Response.Redirect(Globals.NavigateURL());
                        }
                    }

                    if (cmdUpdate.Text == "Signup")
                    {
                        var custom = new ArrayList();
                        custom.Add(DateTime.Now.ToString());
                        custom.Add(txtVendorName.Text);
                        custom.Add(txtFirstName.Text);
                        custom.Add(txtLastName.Text);
                        custom.Add(addresssVendor.Unit);
                        custom.Add(addresssVendor.Street);
                        custom.Add(addresssVendor.City);
                        custom.Add(addresssVendor.Region);
                        custom.Add(addresssVendor.Country);
                        custom.Add(addresssVendor.Postal);
                        custom.Add(addresssVendor.Telephone);
                        custom.Add(addresssVendor.Fax);
                        custom.Add(addresssVendor.Cell);
                        custom.Add(txtEmail.Text);
                        custom.Add(txtWebsite.Text);
                        //send email to Admin
                        Mail.SendEmail(PortalSettings.Email,
                                       PortalSettings.Email,
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_ADMINISTRATOR_SUBJECT"),
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_ADMINISTRATOR_BODY", Localization.GlobalResourceFile, custom));


                        //send email to vendor
                        custom.Clear();
                        custom.Add(txtFirstName.Text);
                        custom.Add(txtLastName.Text);
                        custom.Add(txtVendorName.Text);

                        Mail.SendEmail(PortalSettings.Email,
                                       txtEmail.Text,
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_SUBJECT"),
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_BODY", Localization.GlobalResourceFile, custom));


                        ReturnUrl(txtVendorName.Text.Substring(0, 1));
                    }
                    else
                    {
                        ReturnUrl(Convert.ToString(ViewState["filter"]));
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #2
0
        /// <summary>
        /// cmdUpdate_Click runs when the Update button is clicked.
        /// </summary>
        /// <history>
        ///     [cnurse]	9/17/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    int intPortalID;
                    if (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId)
                    {
                        intPortalID = -1;
                    }
                    else
                    {
                        intPortalID = PortalId;
                    }

                    VendorController objVendors = new VendorController();
                    VendorInfo       objVendor  = new VendorInfo();

                    objVendor.PortalId   = intPortalID;
                    objVendor.VendorId   = VendorID;
                    objVendor.VendorName = txtVendorName.Text;
                    objVendor.UserName   = UserInfo.UserID.ToString();
                    objVendor.Authorized = chkAuthorized.Checked;

                    if (VendorID == -1)
                    {
                        try
                        {
                            VendorID = objVendors.AddVendor(objVendor);
                        }
                        catch
                        {
                            AddModuleMessage("ErrorAddVendor", ModuleMessageType.RedError);
                            return;
                        }
                    }
                    else
                    {
                        VendorInfo objVendorCheck = objVendors.GetVendor(VendorID, intPortalID);
                        if (objVendorCheck != null)
                        {
                            objVendors.UpdateVendor(objVendor);
                        }
                        else
                        {
                            Response.Redirect(Globals.NavigateURL());
                        }
                    }

                    if (cmdUpdate.Text == "Signup")
                    {
                        ArrayList Custom = new ArrayList();
                        Custom.Add(DateTime.Now.ToString());
                        Custom.Add(txtVendorName.Text);
                        string strMessage = "";
                        if (strMessage == "")
                        {
                            Custom.Clear();
                        }
                        else
                        {
                            AddModuleMessage("EmailErrorAdmin", ModuleMessageType.RedError);
                        }

                        if (strMessage == "")
                        {
                            Response.Redirect(Globals.NavigateURL(this.TabId, Null.NullString, "filter=" + txtVendorName.Text.Substring(0, 1)), true);
                        }
                        else
                        {
                            AddModuleMessage("EmailErrorVendor", ModuleMessageType.RedError);
                        }
                    }
                    else
                    {
                        Response.Redirect(Globals.NavigateURL(this.TabId, Null.NullString, "filter=All"), true);
                    }
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #3
0
    protected void btnNewvendor_Click(object sender, EventArgs e)
    {
        if (HiddenVendorEditID.Value != "" && HiddenVendorName.Value != "")
        {
            EditVendor();
            return;
        }
        else if (HiddenVendorEditID.Value == "" && HiddenVendorName.Value == "")
        {
            DataAccess           dacess      = new DataAccess();
            System.Drawing.Image EditedImage = null;
            System.Drawing.Image image       = null;
            //DateTime date = System.DateTime.Now;

            Vendor newVendor = new Vendor();

            DateTime date = Utility.GetCurrentDateTimeinUTC();
            newVendor.ShopCategoryID = Convert.ToInt32(drpVendorcategory.SelectedItem.Value);
            newVendor.VendorName     = txtvendorname.Text;
            newVendor.IconFormat     = FileVendorImg.PostedFile.ContentType;
            newVendor.ContactNumber  = txtvendromobile.Text;
            newVendor.ContactNumber2 = txtMobile2.Text;
            newVendor.Address        = txtvendoraddress.Text;
            newVendor.Address2       = txtvendoraddress2.Text;
            newVendor.InsertDate     = Utility.GetCurrentDateTimeinUTC();
            try
            {
                if (FileVendorImg.HasFile)
                {
                    if (FileVendorImg.PostedFile.ContentLength > 20728650)
                    {
                        lblstatus.Text = "Image Size is large, Please select smaller Image";
                        return;
                    }
                }

                VendorController vendorController = new VendorController();
                int VendorID = vendorController.AddVendor(newVendor);

                if (VendorID > 0)
                {
                    if (FileVendorImg.HasFile)
                    {
                        String Savepath = Request.PhysicalApplicationPath + "Images/Vendor";
                        //FileVendorImg.SaveAs(Savepath + FileVendorImg.FileName);
                        //image = System.Drawing.Image.FromFile(Savepath + FileVendorImg.FileName);

                        string imagename = Path.GetFileNameWithoutExtension(FileVendorImg.FileName);


                        string base64      = Request.Form["imgCropped"];
                        byte[] bytesImages = Convert.FromBase64String(base64.Split(',')[1]);

                        vendorController.AddImage(bytesImages, VendorID, Savepath);
                    }
                    else
                    {
                        FillVendorDataList(muser.currentResident.SocietyID, muser.currentResident.UserType);
                        ClientScript.RegisterStartupScript(this.GetType(), "alert('')", "CloseAddVendor()", true);
                    }
                }
                else
                {
                    lblstatus.Text = "Vendor Added Failed";
                }
            }

            /*
             *          try
             *          {
             *              //Condition to check if the file uploaded or not
             *              if (FileVendorImg.HasFile)
             *              {
             *                  if (FileVendorImg.PostedFile.ContentLength < 20728650)
             *                  {
             *                      //Save  the  image  to  local  folder
             *                      String Savepath = Request.PhysicalApplicationPath + "Images/Vendor";
             *                      //FileVendorImg.SaveAs(Savepath + FileVendorImg.FileName);
             *                      //image = System.Drawing.Image.FromFile(Savepath + FileVendorImg.FileName);
             *
             *                      string imagename = Path.GetFileNameWithoutExtension(FileVendorImg.FileName);
             *
             *
             *                      string base64 = Request.Form["imgCropped"];
             *                      byte[] bytesImages = Convert.FromBase64String(base64.Split(',')[1]);
             *
             *
             *
             *
             *                      using (SqlConnection con1 = new SqlConnection(Utility.SocietyConnectionString))
             *                      {
             *                          con1.Open();
             *                          // SqlCommand cmd = new SqlCommand("INSERT INTO Vendors (ShopCategory,VendorName,ContactNumber,Address,VendorIcon,VendorIconFormat) VALUES (@ShopCategory,@VendorName,@ContactNum,@Address,@VendorIcon,@VendorIconFormat)", con1);
             *                          SqlCommand cmd = new SqlCommand("Insert Into Vendors (ShopCategory,VendorName,ContactNumber,ContactNumber2,Address,Address2,VendorIcon,VendorIconFormat,date,SocietyID,CmdType) Values ('"
             + VendorCat + "','" + Vendorname + "','" + contact + "','" + contact2 + "','" + Address + "','" + Address2 + "',@VendorIcon,'" + VendorIconFormat + "','" + Utility.ChangeDateTimeLocalToSQLServerFormat(date) + "'," + SessionVariables.SocietyID + ",'Insert')", con1);
             +                          cmd.Parameters.Add("@VendorIcon", SqlDbType.Image).Value = bytesImages;
             +                          int count = cmd.ExecuteNonQuery();
             +                          con1.Close();
             +
             +                          if (count == 1)
             +                          {
             +
             +                              FillVendorDataList(muser.currentResident.SocietyID,muser.currentResident.UserType);
             +
             +                          }
             +
             +                          else
             +                          {
             +                              ClientScript.RegisterStartupScript(this.GetType(), "alert('')", "VendorActionPopup()", true);
             +                              lblstatus.Text = "Vendor Added Failed";
             +                              // lblVendrAuctionlMsg.Text = "Vendor Added Failed";
             +                          }
             +                      }
             +                  }
             +              }
             +              else
             +              {
             +                  String InsetdataQuery = "Insert Into Vendors (ShopCategory,VendorName,ContactNumber,ContactNumber2,Address,Address2,date,SocietyID, CmdType) Values ('"
             + VendorCat + "','" + Vendorname + "','" + contact + "','" + contact2 + "','" + Address + "','" + Address2 + "','" + Utility.ChangeDateTimeLocalToSQLServerFormat(date) + "'," + SessionVariables.SocietyID + ",'insert')";
             +                  bool result = dacess.Update(InsetdataQuery);
             +
             +                  if (result == true)
             +                  {
             +                      Response.AddHeader("REFRESH", "50;URL=Vendors.aspx");
             +                      Response.Redirect("Vendors.aspx", false);
             +                  }
             +
             +                  else
             +                  {
             +                      ClientScript.RegisterStartupScript(this.GetType(), "alert('')", "Showpopup()", true);
             +                      lblstatus.Text = "Vendor Added Failed";
             +                  }
             +              }
             +
             +          }
             */
            catch (Exception ex)
            {
                lblstatus.Text = ex.Message;
            }

            finally
            {
                // EditedImage.Dispose();
                // image.Dispose();
                RemoveFiles();
            }
        }
    }
Exemple #4
0
        /// <summary>
        /// cmdUpdate_Click runs when the Update button is clicked.
        /// </summary>
        /// <history>
        ///     [cnurse]	9/17/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    int intPortalID;
                    if (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId)
                    {
                        intPortalID = -1;
                    }
                    else
                    {
                        intPortalID = PortalId;
                    }

                    VendorController objVendors = new VendorController();
                    VendorInfo       objVendor  = new VendorInfo();

                    objVendor.PortalId   = intPortalID;
                    objVendor.VendorId   = VendorID;
                    objVendor.VendorName = txtVendorName.Text;
                    objVendor.Unit       = addresssVendor.Unit;
                    objVendor.Street     = addresssVendor.Street;
                    objVendor.City       = addresssVendor.City;
                    objVendor.Region     = addresssVendor.Region;
                    objVendor.Country    = addresssVendor.Country;
                    objVendor.PostalCode = addresssVendor.Postal;
                    objVendor.Telephone  = addresssVendor.Telephone;
                    objVendor.Fax        = addresssVendor.Fax;
                    objVendor.Cell       = addresssVendor.Cell;
                    objVendor.Email      = txtEmail.Text;
                    objVendor.Website    = txtWebsite.Text;
                    objVendor.FirstName  = txtFirstName.Text;
                    objVendor.LastName   = txtLastName.Text;
                    objVendor.UserName   = UserInfo.UserID.ToString();
                    objVendor.LogoFile   = ctlLogo.Url;
                    objVendor.KeyWords   = txtKeyWords.Text;
                    objVendor.Authorized = chkAuthorized.Checked;

                    if (VendorID == -1)
                    {
                        try
                        {
                            VendorID = objVendors.AddVendor(objVendor);
                        }
                        catch
                        {
                            AddModuleMessage("ErrorAddVendor", ModuleMessageType.RedError);
                            return;
                        }
                    }
                    else
                    {
                        VendorInfo objVendorCheck = objVendors.GetVendor(VendorID, intPortalID);
                        if (objVendorCheck != null)
                        {
                            objVendors.UpdateVendor(objVendor);
                        }
                        else
                        {
                            Response.Redirect(Globals.NavigateURL());
                        }
                    }

                    // update vendor classifications
                    ClassificationController objClassifications = new ClassificationController();
                    objClassifications.DeleteVendorClassifications(VendorID);

                    foreach (ListItem lstItem in lstClassifications.Items)
                    {
                        if (lstItem.Selected)
                        {
                            objClassifications.AddVendorClassification(VendorID, int.Parse(lstItem.Value));
                        }
                    }

                    if (cmdUpdate.Text == "Signup")
                    {
                        ArrayList Custom = new ArrayList();
                        Custom.Add(DateTime.Now.ToString());
                        Custom.Add(txtVendorName.Text);
                        Custom.Add(txtFirstName.Text);
                        Custom.Add(txtLastName.Text);
                        Custom.Add(addresssVendor.Unit);
                        Custom.Add(addresssVendor.Street);
                        Custom.Add(addresssVendor.City);
                        Custom.Add(addresssVendor.Region);
                        Custom.Add(addresssVendor.Country);
                        Custom.Add(addresssVendor.Postal);
                        Custom.Add(addresssVendor.Telephone);
                        Custom.Add(addresssVendor.Fax);
                        Custom.Add(addresssVendor.Cell);
                        Custom.Add(txtEmail.Text);
                        Custom.Add(txtWebsite.Text);

                        string strMessage = Mail.SendMail(txtEmail.Text, PortalSettings.Email, "", Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_ADMINISTRATOR_SUBJECT"), Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_ADMINISTRATOR_BODY", Localization.GlobalResourceFile, Custom), "", "", " ", "", "", "");

                        if (strMessage == "")
                        {
                            Custom.Clear();
                            Custom.Add(txtFirstName.Text);
                            Custom.Add(txtLastName.Text);

                            strMessage = Mail.SendMail(PortalSettings.Email, txtEmail.Text, "", Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_SUBJECT"), Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_BODY", Localization.GlobalResourceFile, Custom), "", "", " ", "", "", "");
                        }
                        else
                        {
                            AddModuleMessage("EmailErrorAdmin", ModuleMessageType.RedError);
                        }

                        if (strMessage == "")
                        {
                            Response.Redirect(Globals.NavigateURL(this.TabId, Null.NullString, "filter=" + txtVendorName.Text.Substring(0, 1)), true);
                        }
                        else
                        {
                            AddModuleMessage("EmailErrorVendor", ModuleMessageType.RedError);
                        }
                    }
                    else
                    {
                        Response.Redirect(Globals.NavigateURL(this.TabId, Null.NullString, "filter=" + Convert.ToString(ViewState["filter"])), true);
                    }
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }