protected void SaveData() { try { if (vID != null) { //Edit on the object. int Id; if (int.TryParse(vID.ToString(), out Id)) { MadeInfo obj = MadeManager.Select(Id); obj.MadeName = txtName.Text; obj.Status = int.Parse(txtOrder.Text); MadeManager.Update(obj); } } else { //this is a new object. MadeInfo obj = new MadeInfo(); obj.MadeName = txtName.Text; obj.Status = int.Parse(txtOrder.Text); MadeManager.Insert(obj); } lblMessage.Text = "Đã lưu dữ liệu thành công!"; EditPanel.Enabled = false; BindData(); vID = null; } catch (Exception ex) { lblMessage.Text = ex.Message; } }
private void EditData(int Id) { MadeInfo obj = MadeManager.Select((int)Id); txtName.Text = obj.MadeName; txtOrder.Text = obj.Status.ToString(); vID = obj.MadeID; EditPanel.Enabled = true; }