-
Notifications
You must be signed in to change notification settings - Fork 0
/
Create_Company.aspx.cs
executable file
·82 lines (63 loc) · 2.53 KB
/
Create_Company.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.IO;
public partial class Create_Company : System.Web.UI.Page
{
private string Contents = ConfigurationManager.AppSettings["Contents"].ToString();
private string repository = ConfigurationManager.AppSettings["repository"].ToString();
private string URL = ConfigurationManager.AppSettings["URL"].ToString();
SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["terrible1ConnectionString"].ToString());
protected void Page_Load(object sender, System.EventArgs e)
{
if (IsPostBack)
{
// If this is a Postback, execute these statements.
}
else
{
// Put code to execute for non postback here
}
}
protected void BtnSave_Click(object sender, System.EventArgs e)
{
Company myCompany;
myCompany = new Company();
myCompany.CompanyName = System.Convert.ToString(txtCompanyName.Text);
myCompany.Description = System.Convert.ToString(txtDescription.Text);
clscompany.Insert(myCompany);
if (FileUploadControl.HasFile)
{
DataView dvSql = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView drvSql in dvSql)
{
HiddenFieldID.Value = drvSql["cID"].ToString();
}
string FileName = Path.GetFileName(FileUploadControl.PostedFile.FileName);
FileUploadControl.SaveAs(repository + FileName);
c.Open();
using (SqlCommand cmd = c.CreateCommand())
{
cmd.Parameters.Clear();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_UpdateCompanyLogo";
cmd.Parameters.Add("@Logo ", SqlDbType.VarChar).Value = FileName;
cmd.Parameters.Add("@URL", SqlDbType.VarChar).Value = URL + FileName;
cmd.Parameters.Add("@CompanyID", SqlDbType.Int).Value = HiddenFieldID.Value;
cmd.ExecuteNonQuery();
}
c.Close();
}
Response.Redirect("CompanyGrid.aspx", false);
}
protected void BtnCancel_Click(object sender, System.EventArgs e)
{
Response.Redirect("CompanyGrid.aspx", false);
}
}