//删除数据 protected void notarizeDelete(object sender, EventArgs e) { int loginid = getLoginUserID(); if (loginid == -1) { return; } int vendor_id = -1; try { vendor_id = int.Parse(vendor_id_delete.Value.ToString()); } catch (Exception ex) { PageUtil.showToast(this, "数据异常,删除失败!"); return; } SupplierDC supplierDC = new SupplierDC(); if (supplierDC.deleteSupplier(vendor_id)) { PageUtil.showToast(this, "数据删除成功!"); string vendor_name1 = vendor_name_id.Value.Trim(); string vendor_key1 = vendor_key_id.Value.Trim(); Line_Repeater.DataSource = supplierDC.getSupplierBySome(vendor_name1, vendor_key1); Line_Repeater.DataBind(); } else { PageUtil.showToast(this, "数据删除失败!"); } }
//查询 protected void selectSome(object sender, EventArgs e) { string vendor_name = vendor_name_id.Value.Trim(); string vendor_key = vendor_key_id.Value.Trim(); SupplierDC supplierDC = new SupplierDC(); DataSet ds = supplierDC.getSupplierBySome(vendor_name, vendor_key); if (ds == null) { PageUtil.showToast(this, "未查询到数据!"); return; } Line_Repeater.DataSource = ds; Line_Repeater.DataBind(); }
//更新数据 protected void notarizeUpdate(object sender, EventArgs e) { int loginid = getLoginUserID(); if (loginid == -1) { return; } string vendor_id = vendor_id_update.Value.Trim(); string vendor_name = vendor_name_update.Value.Trim(); string vendor_key = vendor_key_update.Value.Trim(); if (!checkData(vendor_name, vendor_key)) { return; } SupplierDC supplierDC = new SupplierDC(); DataSet search_ds = supplierDC.getSupplierByNameAndKeyAndId(vendor_id, vendor_name, vendor_key); //如过大于2,则数据库中已存在该name和key,否则 就可以更新 if (search_ds != null && search_ds.Tables[0].Rows.Count > 0) { PageUtil.showToast(this, "供应商名称或者供应商代码已存在!"); return; } if (supplierDC.updateSupplier(vendor_id, vendor_name, loginid, vendor_key, DateTime.Now)) { PageUtil.showToast(this, "数据更新成功!"); string vendor_name1 = vendor_name_id.Value.Trim(); string vendor_key1 = vendor_key_id.Value.Trim(); Line_Repeater.DataSource = supplierDC.getSupplierBySome(vendor_name1, vendor_key1); Line_Repeater.DataBind(); } else { PageUtil.showToast(this, "数据更新失败!"); } }
//插入数据 protected void notarizeInsert(object sender, EventArgs e) { int loginid = getLoginUserID(); if (loginid == -1) { return; } string vendor_name = vendor_name_insert.Value.Trim(); string vendor_key = vendor_key_insert.Value.Trim(); if (!checkData(vendor_name, vendor_key)) { return; } SupplierDC supplierDC = new SupplierDC(); DataSet search_ds = supplierDC.getSupplierByNameAndKey(vendor_name, vendor_key); if (search_ds != null && search_ds.Tables[0].Rows.Count > 0) { PageUtil.showToast(this, "供应商名称或者供应商代码已存在!"); return; } else if (supplierDC.insertSupplier(vendor_name, loginid, vendor_key, DateTime.Now)) { PageUtil.showToast(this, "数据插入成功!"); vendor_name_insert.Value = ""; vendor_key_insert.Value = ""; Line_Repeater.DataSource = supplierDC.getSupplierBySome("", ""); Line_Repeater.DataBind(); } else { PageUtil.showToast(this, "数据插入失败!"); } }