/
Comment.aspx.cs
67 lines (61 loc) · 3.57 KB
/
Comment.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
using System;
using System.Linq;
public partial class Comment : System.Web.UI.Page
{
Ajancy.Kimia_Ajancy db = null;
protected void drpAjancyType_SelectedIndexChanged(object sender, EventArgs e)
{
LoadAjancies();
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
Ajancy.Comment comment = new Ajancy.Comment();
comment.DriverFirstName = this.txtDriverFirstName.Text;
comment.DriverLastName = this.txtDriverLastName.Text;
comment.FirstName = this.txtFirstName.Text;
comment.LastName = this.txtLastName.Text;
comment.Phone = this.txtPhone.Text;
comment.Email = this.txtEmail.Text;
comment.AjancyID = Public.ToInt(this.drpAjancies.SelectedValue);
comment.Subject = Public.ToByte(this.drpSubject.SelectedValue);
comment.ProblemDate = new DateTime(this.txtProblemDate.GeorgianDate.Value.Year, this.txtProblemDate.GeorgianDate.Value.Month, this.txtProblemDate.GeorgianDate.Value.Day, this.txtTime.Time.Hours, this.txtTime.Time.Minutes, 0);
comment.CommentText = this.txtComment.Text;
comment.SubmitDate = DateTime.Now;
db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
if (!string.IsNullOrEmpty(this.txtCarPlateNumber_1.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_2.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_3.Text))
{
Ajancy.PlateNumber plateNumber = db.PlateNumbers.FirstOrDefault<Ajancy.PlateNumber>(pn => pn.TwoDigits == this.txtCarPlateNumber_1.Text &&
pn.Alphabet == this.drpCarPlateNumber.SelectedValue &&
pn.ThreeDigits == this.txtCarPlateNumber_3.Text &&
pn.RegionIdentifier == this.txtCarPlateNumber_3.Text);
if (plateNumber == null)
{
this.lblMessage.Text = "کابر گرامی شماره پلاک مورد نظر شما متعلق به رانندگان این اتحادیه نمیباشد در صورت اطمینان از درست بودن شماره پلاک در قسمت توضیحات آنرا بنویسید";
return;
}
comment.PlateNumberID = plateNumber.PlateNumberID;
}
db.Comments.InsertOnSubmit(comment);
db.SubmitChanges();
Response.Redirect("~/Default.aspx");
}
}
private void LoadAjancies()
{
if (this.drpAjancyType.SelectedIndex > 0)
{
this.drpAjancies.Items.Clear();
db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
this.drpAjancies.DataSource = db.Ajancies.Where(aj => aj.AjancyType == Public.ToByte(this.drpAjancyType.SelectedValue)).Select(aj => new { aj.AjancyID, aj.AjancyName });
this.drpAjancies.DataBind();
this.drpAjancies.Items.Insert(0, new System.Web.UI.WebControls.ListItem("- انتخاب کنید -", "0"));
}
else
{
this.drpAjancies.Items.Clear();
this.drpAjancies.Items.Insert(0, new System.Web.UI.WebControls.ListItem("- انتخاب کنید -", "0"));
}
}
}