public ActionResult Create(Group collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here GroupDao bdDao = new GroupDao(); // UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; //collection.CreateDate = Hepper.GetDateServer(); //collection.ModifiedDate = Hepper.GetDateServer(); //collection.CreateBy = us.UserName; //collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection)) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không thêm được", "danger"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
private void Insert(DataRow row) { try { GroupDao.Insert(_ConfigItem, row); } catch (Exception ex) { throw ex; } }
private void B_ADD_Click(object sender, EventArgs e) { if (isValidInputData()) { ModelGroup model = new ModelGroup(); model.id = this.id; model.group_code = txtCode.Text; model.group_description = txtDesc.Text; model.group_order = Convert.ToInt32(txtOrder.Text); Boolean result = false; switch (B_ADD.Text) { case "บันทึก": //Check Exist List <ModelGroup> stationLists = groupDao.Select(" Where group_code='" + model.group_code + "'"); if (stationLists.Count > 0) { MessageBox.Show("มีข้อมูล " + model.group_code + " ในระบบแล้ว"); txtCode.SelectAll(); txtCode.Focus(); //txtDesc.Text = ""; } else { result = groupDao.Insert(model); if (result) { MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว"); } } break; case "แก้ไข": result = groupDao.Update(model); if (result) { MessageBox.Show("แก้ไขข้อมูลเรียบร้อยแล้ว"); } break; } if (result) { refresh(); } } }
public void Submit_OnClick(object sender, EventArgs e) { var isWriting = Convert.ToBoolean(DdlIsEnabled.SelectedValue); if (isWriting) { if (!Main.Instance.AdminApi.IsAdminNameExists(TbAdmin.Text)) { LtlMessage.Text = Utils.GetMessageHtml("关联管理员不存在,请重新填写!", false); return; } } var userNameList = new List <string>(); foreach (var userNameStr in TbUsers.Text.Trim().Split(',')) { if (string.IsNullOrEmpty(userNameStr)) { continue; } var userName = userNameStr.Trim(); if (!userNameList.Contains(userName) && Main.Instance.UserApi.IsUserNameExists(userName)) { userNameList.Add(userName); } } if (!string.IsNullOrEmpty(Request.QueryString["add"]) && _groupInfo.Id == 0) { _groupInfo.GroupName = TbGroupName.Text; _groupInfo.IsWriting = isWriting; _groupInfo.WritingAdmin = TbAdmin.Text; _groupInfo.Id = GroupDao.Insert(_groupInfo); } else { if (_groupInfo.Id == 0) { _configInfo.IsWriting = isWriting; _configInfo.WritingAdmin = TbAdmin.Text; Main.Instance.ConfigApi.SetConfig(0, _configInfo); } else { _groupInfo.GroupName = TbGroupName.Text; _groupInfo.IsWriting = isWriting; _groupInfo.WritingAdmin = TbAdmin.Text; GroupDao.Update(_groupInfo); } } if (_groupInfo.Id > 0) { GroupUserDao.Delete(_groupInfo.Id); foreach (var userName in userNameList) { GroupUserDao.Insert(_groupInfo.Id, userName); } } Response.Redirect(PageWriting.GetRedirectUrl()); }