protected void bindtemplate() { objadmin.action = "selecttemplate"; objadmin.companyId = Session["companyid"].ToString(); ds = objadmin.ManageSettings(); if (ds.Tables[0].Rows.Count > 0) { dltemplate.DataSource = ds.Tables[0]; dltemplate.DataBind(); } }
protected void btnupload_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { string filename = ""; string path2 = ""; try { objuser.id = Session["userid"].ToString(); TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); string FormatedDateTime = Convert.ToInt64(ts.TotalSeconds).ToString(); string ssUniqueId = DateTime.UtcNow.ToString("fffffff"); string date = DateTime.Now.ToString("MMddyyyy"); string unid = date + "_" + ssUniqueId; String extension = Path.GetExtension(FileUpload1.PostedFile.FileName); if (extension.ToUpper() != ".JPG" && extension.ToUpper() != ".JPEG" && extension.ToUpper() != ".PNG" && extension.ToUpper() != ".GIF") { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script type='text/javascript'>alert('Selected file has invalid format');</script>", false); return; } filename = unid + extension; ViewState["logourl"] = filename; //string path = Server.MapPath(FileUpload1.PostedFile.FileName); string path = AppDomain.CurrentDomain.BaseDirectory + "\\webfile\\" + filename; ViewState["path"] = @"webfile/" + filename; FileUpload1.SaveAs(path); path = Server.MapPath("webfile/" + filename); divbiglogo.InnerHtml = "<img src='webfile/" + filename + "' width='100%' heignt='100%' />"; } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script type='text/javascript'>alert('" + ex.ToString() + "'Server error please try again later.');</script>", false); return; } objadmin.logoURL = ViewState["logourl"].ToString(); objadmin.companyId = Session["companyid"].ToString(); objadmin.action = "changelogo"; ds = objadmin.ManageSettings(); binddetail(); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script type='text/javascript'>alert('Please select a file');</script>", false); return; } }
protected void Page_Load(object sender, EventArgs e) { objgen.validatelogin(); if (!Page.IsPostBack) { if (!objda.checkUserInroles("3")) { Response.Redirect("UserDashboard.aspx"); } ClsAdmin objadmin = new ClsAdmin(); objadmin.action = "select"; objadmin.companyId = Session["companyid"].ToString(); ds = objadmin.ManageSettings(); var ad_origin = new AddressData { Address = ds.Tables[0].Rows[0]["address"].ToString(), City = ds.Tables[0].Rows[0]["cityid"].ToString(), State = ds.Tables[0].Rows[0]["stateid"].ToString(), Country = ds.Tables[0].Rows[0]["countryid"].ToString(), Zip = ds.Tables[0].Rows[0]["zip"].ToString() }; Session["origin"] = ad_origin; hidaddress.Value = ad_origin.ToString(); fillgrid(); } }
public string GetCompanyProperty(string property) { ClsAdmin objadmin = new ClsAdmin(); string result = ""; objadmin.action = "select"; objadmin.companyId = HttpContext.Current.Session["companyid"].ToString(); ds = objadmin.ManageSettings(); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["" + property + ""] != null) { result = ds.Tables[0].Rows[0]["" + property + ""].ToString(); } } if (result == "") { result = System.Web.Configuration.WebConfigurationManager.AppSettings["" + property + ""].ToString(); } return(result); }
public string SendEmail(string receiver, string subject, string message, string cc, string bcc, string filename, string companyid) { string sender = System.Web.Configuration.WebConfigurationManager.AppSettings["SenderEmail"].ToString(); string pass = System.Web.Configuration.WebConfigurationManager.AppSettings["SenderPass"].ToString(); string hostname = System.Web.Configuration.WebConfigurationManager.AppSettings["MailHost"].ToString(); ClsAdmin objadmin = new ClsAdmin(); objadmin.action = "select"; objadmin.companyId = companyid; ds = objadmin.ManageSettings(); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["SenderEmail"].ToString() != "" && ds.Tables[0].Rows[0]["SenderPass"].ToString() != "") { sender = ds.Tables[0].Rows[0]["SenderEmail"].ToString(); pass = ds.Tables[0].Rows[0]["SenderPass"].ToString(); hostname = ds.Tables[0].Rows[0]["MailHost"].ToString(); } } System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); string msg = ""; if (receiver != "") { string[] strto = receiver.Split(','); for (int i = 0; i < strto.Length - 1; i++) { if (strto[i] != "") { mail.To.Add(new MailAddress(strto[i])); } } } mail.From = new MailAddress(sender); mail.Subject = subject; mail.Body = message; if (cc != "") { string[] strcc = cc.Split(','); for (int i = 0; i < strcc.Length - 1; i++) { mail.CC.Add(new MailAddress(strcc[i])); } } if (bcc != "") { string[] strbcc = bcc.Split(','); for (int i = 0; i < strbcc.Length - 1; i++) { mail.Bcc.Add(new MailAddress(strbcc[i])); } } if (filename != "") { mail.Attachments.Add(new System.Net.Mail.Attachment(HttpContext.Current.Server.MapPath("webfile/temp/" + filename))); } mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = hostname; smtp.Credentials = new System.Net.NetworkCredential(sender, pass); // smtp.DeliveryMethod = SmtpDeliveryMethod.Network; //smtp.Port = 25; //smtp.EnableSsl = true; try { smtp.Send(mail); msg = "Sent"; } catch (Exception ex) { msg = ex.ToString(); } return(msg); }
protected void binddetail() { objadmin.action = "select"; objadmin.companyId = Session["companyid"].ToString(); ds = objadmin.ManageSettings(); if (ds.Tables[0].Rows.Count > 0) { Response.Cookies["user"]["companyname"] = HttpUtility.UrlEncode(ds.Tables[0].Rows[0]["companyname"].ToString()); Response.Cookies["user"]["companyaddress"] = HttpUtility.UrlEncode(ds.Tables[0].Rows[0]["companyfulladdress"].ToString()); Session["companyaddress"] = ds.Tables[0].Rows[0]["companyfulladdress"].ToString(); Session["companyname"] = ds.Tables[0].Rows[0]["companyname"].ToString(); litcompanyname.Text = ds.Tables[0].Rows[0]["companyname"].ToString(); litemail.Text = ds.Tables[0].Rows[0]["email"].ToString(); litwebsite.Text = ds.Tables[0].Rows[0]["website"].ToString(); txtcompanyName.Text = ds.Tables[0].Rows[0]["companyname"].ToString(); txtEmail.Text = ds.Tables[0].Rows[0]["email"].ToString(); txtwebsite.Text = ds.Tables[0].Rows[0]["website"].ToString(); txtmailhost.Text = ds.Tables[0].Rows[0]["MailHost"].ToString(); txtreceiveremail.Text = ds.Tables[0].Rows[0]["ReceiverMail"].ToString(); txtsenderEmail.Text = ds.Tables[0].Rows[0]["SenderEmail"].ToString(); txtsenderpass.Text = ds.Tables[0].Rows[0]["SenderPass"].ToString(); txtservercompanyname.Text = ds.Tables[0].Rows[0]["ServerCompnyName"].ToString(); txtnextinvoiceno.Text = ds.Tables[0].Rows[0]["fistinvno"].ToString(); txtprefix.Text = ds.Tables[0].Rows[0]["invprefix"].ToString(); txtpostfix.Text = ds.Tables[0].Rows[0]["invpostfix"].ToString(); txtUserName.Text = ds.Tables[0].Rows[0]["usrNameAtendnceReadr"].ToString(); txtPassword.Text = ds.Tables[0].Rows[0]["paswrdAtendnceReadr"].ToString(); hidleaveemailemp.Value = ds.Tables[0].Rows[0]["LeaveEmail"].ToString(); hidscheduleemailemp.Value = ds.Tables[0].Rows[0]["ScheduleEmail"].ToString(); rdlemailnoti.Text = ds.Tables[0].Rows[0]["EmailNotification"].ToString(); ddlcurrency.Text = ds.Tables[0].Rows[0]["currencyid"].ToString(); droptimezone.Text = ds.Tables[0].Rows[0]["timezone"].ToString(); if (ds.Tables[0].Rows[0]["logoURL"].ToString() != "") { divuserphoto.Src = "webfile/" + ds.Tables[0].Rows[0]["logoURL"].ToString(); ViewState["logourl"] = ds.Tables[0].Rows[0]["logoURL"].ToString(); } else { divuserphoto.Src = "webfile/" + ds.Tables[0].Rows[0]["logoURL"].ToString(); } } if (ds.Tables.Count > 1) { if (ds.Tables[1].Rows.Count > 0) { for (int i = 0; i < ds.Tables[1].Rows.Count; i++) { for (int j = 0; j < listcode1.Items.Count; j++) { if (listcode1.Items[j].Value == ds.Tables[1].Rows[i]["nid"].ToString()) { ListItem li = new ListItem(listcode1.Items[j].Text, listcode1.Items[j].Value); listcode2.Items.Add(li); listcode1.Items.RemoveAt(j); break; } } } } if (ds.Tables[2].Rows.Count > 0) { for (int i = 0; i < ds.Tables[2].Rows.Count; i++) { for (int j = 0; j < listleave1.Items.Count; j++) { if (listleave1.Items[j].Value == ds.Tables[2].Rows[i]["nid"].ToString()) { ListItem li = new ListItem(listleave1.Items[j].Text, listleave1.Items[j].Value); listleave2.Items.Add(li); listleave1.Items.RemoveAt(j); break; } } } } } }