protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Session["FCKeditor:UserFilesPath"] = ConfigurationManager.AppSettings["OutstandingFilePath"]; if (CurrentOutStanding != 0) { //BindData(); DBLayer db = new DBLayer(); DataSet ds = new DataSet(); ds = db.GetOutstanding(CurrentOutStanding); if (ds.Tables[0].Rows.Count > 0) { uiTextBoxEnName.Text = ds.Tables[0].Rows[0]["ENName"].ToString(); uiTextBoxArName.Text = ds.Tables[0].Rows[0]["ArName"].ToString(); uiImagePic.ImageUrl = ds.Tables[0].Rows[0]["PicturePath"].ToString(); uiTextBoxYear.Text = ds.Tables[0].Rows[0]["Date"].ToString(); uiFCKeditorEnComment.Value = Server.HtmlDecode(ds.Tables[0].Rows[0]["ENComments"].ToString()); uiFCKeditorArComment.Value = Server.HtmlDecode(ds.Tables[0].Rows[0]["ARComments"].ToString()); uiDropDownListClass.SelectedValue = ds.Tables[0].Rows[0]["ClassID"].ToString(); } uiPanelCurrentOutStanding.Visible = false; uiPanelCurrent.Visible = true; } else { uiPanelCurrentOutStanding.Visible = true; uiPanelCurrent.Visible = false; BindData(); LoadDDLs(); } } }
protected void uiButtonUpdate_Click(object sender, EventArgs e) { DBLayer db = new DBLayer(); string temp = ""; string filepath = ""; DataSet ds = new DataSet(); if (uiFileUploadPicture.HasFile) { uiFileUploadPicture.SaveAs(Server.MapPath(ConfigurationManager.AppSettings["OutstandingFilePath"] + uiFileUploadPicture.FileName)); filepath = ConfigurationManager.AppSettings["OutstandingFilePath"].Substring(1) + uiFileUploadPicture.FileName; } ds = db.GetOutstanding(CurrentOutStanding); if (ds.Tables[0].Rows.Count > 0) { temp = ds.Tables[0].Rows[0]["PicturePath"].ToString(); } if (CurrentOutStanding != 0) { if (temp != filepath && string.IsNullOrEmpty(filepath)) db.UpdateOutstanding(CurrentOutStanding, uiTextBoxEnName.Text, uiTextBoxArName.Text, temp, DateTime.Now, Convert.ToInt32(uiDropDownListClass.SelectedValue), Server.HtmlEncode(uiFCKeditorEnComment.Value), Server.HtmlEncode(uiFCKeditorArComment.Value)); else db.UpdateOutstanding(CurrentOutStanding, uiTextBoxEnName.Text, uiTextBoxArName.Text, filepath, DateTime.Now, Convert.ToInt32(uiDropDownListClass.SelectedValue), Server.HtmlEncode(uiFCKeditorEnComment.Value), Server.HtmlEncode(uiFCKeditorArComment.Value)); } else { db.AddOutStanding(uiTextBoxEnName.Text, uiTextBoxArName.Text, filepath, DateTime.Now, Convert.ToInt32(uiDropDownListClass.SelectedValue), Server.HtmlEncode(uiFCKeditorEnComment.Value), Server.HtmlEncode(uiFCKeditorArComment.Value)); } CurrentOutStanding = 0; uiPanelCurrentOutStanding.Visible = true; uiPanelCurrent.Visible = false; BindData(); }
protected void uiGridViewOutstanding_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditOutStanding") { int id = Convert.ToInt32(e.CommandArgument.ToString()); CurrentOutStanding = id; DBLayer db = new DBLayer(); DataSet ds = new DataSet(); ds = db.GetOutstanding(id); if (ds.Tables[0].Rows.Count > 0) { uiTextBoxEnName.Text = ds.Tables[0].Rows[0]["ENName"].ToString(); uiTextBoxArName.Text = ds.Tables[0].Rows[0]["ArName"].ToString(); uiImagePic.ImageUrl = ds.Tables[0].Rows[0]["PicturePath"].ToString(); uiTextBoxYear.Text = ds.Tables[0].Rows[0]["Date"].ToString(); uiFCKeditorEnComment.Value = Server.HtmlDecode(ds.Tables[0].Rows[0]["ENComments"].ToString()); uiFCKeditorArComment.Value = Server.HtmlDecode(ds.Tables[0].Rows[0]["ARComments"].ToString()); uiDropDownListClass.SelectedValue = ds.Tables[0].Rows[0]["ClassID"].ToString(); } uiPanelCurrentOutStanding.Visible = false; uiPanelCurrent.Visible = true; } else if (e.CommandName == "DeleteOutStanding") { int id = Convert.ToInt32(e.CommandArgument.ToString()); CurrentOutStanding = id; DBLayer db = new DBLayer(); db.DeleteOutstanding(id); uiPanelCurrentOutStanding.Visible = true; uiPanelCurrent.Visible = false; BindData(); } }