private void btnDelete_Click(object sender, EventArgs e) { // nhan vao name -> delete TreeBLL treeBLL = new TreeBLL(); if (treeBLL.DeteleTree(txtName.Text)) { MessageBox.Show("Success"); if (!clicked_btnClear) { //delete DataRow r = dtTree.Rows.Find(txtName.Text); dtTree.Rows.Remove(r); } else { LoadData(); clicked_btnClear = false; } } else { MessageBox.Show("Cannot delete cuz foreign key "); } }
private void LoadData() { TreeBLL treeBLL = new TreeBLL(); dtTree = treeBLL.gettAllTree(); dgvShopping.DataSource = getTable(dtTree); }
private void btnSearch_Click(object sender, EventArgs e) { DataTable dtView = getTable(dtTree); string searchValue = txtSearchUser.Text; TreeBLL treeBll = new TreeBLL(); string filter = "Name LIKE '%" + searchValue + "%'"; DataView view = dtView.DefaultView; view.RowFilter = filter; dgvShopping.DataSource = view; }
public void GetDTreeJSON() { TreeBLL bll = new TreeBLL(); string id = Request.Form["id"]; if (id == null) { StringJSON = bll.GetBetRecordTree("1"); } else if (id != null) { StringJSON = bll.GetBetRecordTree(id); } else { Response.Write("success:false"); } }
internal bool Save(FlowDocument fd, string diaryTime) { bool isok = false; DateTime datetime = Convert.ToDateTime(diaryTime); TextRange textRange = new TextRange(fd.ContentStart, fd.ContentEnd); DiaryModel diaOld = getTodayDiary(datetime); DiaryDAL diaryDal = new DiaryDAL(); TreeBLL treeBll = new TreeBLL(); //如果内容清空表示删除日记 if (textRange.Text.Length <= 0) { if (diaOld != null) { diaryDal.DeleteById(diaOld.ID); treeBll.Delete(diaOld.ID); } return true; } //保存日记内容 DiaryModel diaNew = new DiaryModel(); string contents = XamlHelper.ToXaml(fd); int pubTime = TimesTampHelper.ConvertDateTimeInt(datetime); string title = datetime.ToString("yyyy-MM-dd") + " " + datetime.DayOfWeek; diaNew.Title = title; diaNew.PubTime = pubTime; diaNew.Contents = contents; //查找是否有当天内容 if (diaOld != null) { diaNew.ID = diaOld.ID; diaNew.PubTime = diaOld.PubTime; return diaryDal.Update(diaNew); } int lastID = diaryDal.Insert(diaNew); isok = treeBll.Save(lastID, datetime); return isok; }
private void btnCancel_Click(object sender, EventArgs e) { // Cong lai so luong trong bang tree TreeBLL treeBLL = new TreeBLL(); foreach (DataRow row in dt.Rows) { string name = row.Field <string>(2).ToString(); int quantity = int.Parse(row.Field <int>(3).ToString()); treeBLL.IncreaseQuantity(name, quantity); } TransactionBLL transactionBLL = new TransactionBLL(); if (transactionBLL.SetStatus("Cancel", IDTrans)) { MessageBox.Show("Cancel"); } this.Close(); }
private void btnCancel_Click(object sender, EventArgs e) { int IDTrans = int.Parse(dgvHistory.Rows[RowIndex].Cells[0].Value.ToString()); DataRow row = dt.Rows.Find(IDTrans); string status = row.Field <string>(4).ToString(); if (status.Equals("Active")) // neu status eq 'Active' means Admin has not approve yet. - > allow cancel { if (MessageBox.Show("Are you really want to cancel :( ", "Notice", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { // Cong lai so luong trong bang tree TreeBLL treeBLL = new TreeBLL(); OrderBLL orderBLL = new OrderBLL(); DataTable dtOrders = new DataTable(); dtOrders = orderBLL.getOrders(IDTrans); foreach (DataRow r in dtOrders.Rows) { string name = r.Field <string>(2).ToString(); int quantity = int.Parse(r.Field <int>(3).ToString()); treeBLL.IncreaseQuantity(name, quantity); } // update database and update table TransactionBLL transactionBLL = new TransactionBLL(); if (transactionBLL.CancelOrdering(IDTrans)) { MessageBox.Show("Canceled!"); row["Status"] = "Cancel"; dgvHistory.Refresh(); } } } else if (status.Equals("Delivering")) { MessageBox.Show("Cannot cancel your order cuz it's delivering"); } else { MessageBox.Show("It's alreadly canceled"); } }
private void LoadData() { dtTree = new DataTable(); dtCategory = new DataTable(); // get data for 2 table TreeBLL treeBLL = new TreeBLL(); dtTree = treeBLL.gettAllTree(); CategoryBLL categoryBLL = new CategoryBLL(); dtCategory = categoryBLL.getAll(); //Khai bao cot BookID la khoa chinh dtTree.PrimaryKey = new DataColumn[] { dtTree.Columns[0] }; //binding to ComboBox : complex binding cbCatageryName.DataSource = dtCategory; cbCatageryName.DisplayMember = "Category"; cbCatageryName.ValueMember = "ID"; //Binding GridView voi ComboBox cbCatageryName.DataBindings.Clear(); cbCatageryName.DataBindings.Add("SelectedValue", dtTree, "CategoryID"); //binding to DataGridView : Complex Binding dgvTree.DataSource = dtTree; //Binding to TextBoxes: Simple Binding txtName.DataBindings.Clear(); txtPrice.DataBindings.Clear(); txtQuantity.DataBindings.Clear(); txtDescription.DataBindings.Clear(); // Picture box duoc bat su kien o cellClick cua dgvTree txtDescription.DataBindings.Add("Text", dtTree, "Description"); txtName.DataBindings.Add("Text", dtTree, "Name"); txtPrice.DataBindings.Add("Text", dtTree, "Price"); txtQuantity.DataBindings.Add("Text", dtTree, "Quantity"); }
private void btnAdd_Click(object sender, EventArgs e) { if (!clicked_btnClear) { MessageBox.Show("Pls Clear the data first to use Add function"); return; } if (ValidationData()) { TreeBLL treeBLL = new TreeBLL(); string categoryId = cbCatageryName.SelectedValue.ToString(); bool check = treeBLL.CreateTree(txtName.Text, imageURl, txtDescription.Text, float.Parse(txtPrice.Text), cbCatageryName.SelectedValue.ToString(), int.Parse(txtQuantity.Text)); if (check) { MessageBox.Show("Success"); LoadData(); clicked_btnClear = false; imageURl = ""; } } txtName.ReadOnly = true; }
private void btnUpdate_Click(object sender, EventArgs e) { if (validationUpdate()) { TreeBLL treeBLL = new TreeBLL(); string name = txtName.Text; string description = txtDescription.Text; int quantity = int.Parse(txtQuantity.Text); float price = float.Parse(txtPrice.Text); string catagoryid = cbCatageryName.SelectedValue.ToString(); string image = imageURl; if (treeBLL.UpdateTree(name, image, description, price, catagoryid, quantity)) { if (!clicked_btnClear) { // update table DataRow row = dtTree.Rows.Find(name); row["Image"] = image; row["Description"] = description; row["Price"] = price; row["CategoryID"] = catagoryid; row["Status"] = "Active"; row["Quantity"] = quantity; dgvTree.Refresh(); MessageBox.Show("Save successful"); } else { LoadData(); clicked_btnClear = false; } } } }