//删除收款凭证 private void DeleteShoukuan(String id) { List <SearchField> condition = new List <SearchField>(); CommTable com1 = new CommTable(); com1.TableConnect.BeginTrans(); try { com1.TabName = "CW_ShouKuan"; condition.Add(new SearchField("id", id, SearchFieldType.数值型)); DataSet ds1 = com1.SearchData("*", condition); if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { DataRow dr1 = ds1.Tables[0].Rows[0]; String zcid = dr1["zcid"].ToString(); String checktime = dr1["checktime"].ToString().Trim(); double pbj = 0; if (String.IsNullOrEmpty(dr1["pbj"].ToString().Trim()) == false) { pbj = double.Parse(dr1["pbj"].ToString()); } double plx = 0; if (String.IsNullOrEmpty(dr1["plx"].ToString().Trim()) == false) { plx = double.Parse(dr1["plx"].ToString()); } //删除收款凭证的数据 dr1.Delete(); com1.Update(ds1); //如果收款凭证已审核,则需调整资产中的相关数据 if (String.IsNullOrEmpty(checktime) == false) { com1.TabName = "u_zc3"; condition.Clear(); condition.Add(new SearchField("id", zcid, SearchFieldType.数值型)); DataSet ds2 = com1.SearchData("*", condition); if (ds2 != null && ds2.Tables[0].Rows.Count > 0) { DataRow dr2 = ds2.Tables[0].Rows[0]; dr2["pbj"] = double.Parse(dr2["pbj"].ToString()) - pbj; dr2["plx"] = double.Parse(dr2["plx"].ToString()) - plx; com1.Update(ds2); } } } com1.TableConnect.CommitTrans(); } catch (Exception err) { com1.TableConnect.RollBackTrans(); } finally { com1.Close(); } }
//审批档案,agree为true表示同意,agree为false表示不同意 public static void ShenPiDangAn(String ID, bool agree) { CommTable com1 = new CommTable("DA_JyBill"); List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("id", ID, SearchFieldType.数值型)); DataSet ds1 = com1.SearchData("*", condition); if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { DataRow dr1 = ds1.Tables[0].Rows[0]; if (agree) { dr1["status"] = "1"; } else { dr1["status"] = "0"; } dr1["checkman"] = Comm.CurUser; dr1["checktime"] = DateTime.Now.ToString(); dr1["time1"] = DateTime.Now.AddMonths(1); com1.Update(ds1); } com1.Close(); }
//更新管理员 public static void UpdateAdmin(String id, String num, String depart, String sname) { if (String.IsNullOrEmpty(id)) { id = "-1"; } DataRow dr1 = null; CommTable comm1 = new CommTable("U_DepartDangAnAdminUsers"); List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("id", id, SearchFieldType.数值型)); DataSet ds1 = comm1.SearchData("*", condition); if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { dr1 = ds1.Tables[0].Rows[0]; dr1["num"] = num; dr1["depart"] = depart; dr1["sname"] = sname; } else { dr1 = ds1.Tables[0].NewRow(); dr1["num"] = num; dr1["depart"] = depart; dr1["sname"] = sname; ds1.Tables[0].Rows.Add(dr1); } comm1.Update(ds1); comm1.Close(); }
protected void Button2_Click(object sender, EventArgs e) { String sel = Request.Form["selFile"]; if (String.IsNullOrEmpty(sel) == false) { CommTable comm1 = new CommTable(); comm1.TabName = "U_CZFile"; List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("id", sel, SearchOperator.集合, SearchFieldType.数值型)); DataSet ds1 = comm1.SearchData("*", condition); foreach (DataRow dr in ds1.Tables[0].Rows) { String fileName = dr["FileName"].ToString(); dr.Delete(); String file1 = Server.MapPath("~/Common/AttachFiles/" + fileName); if (File.Exists(file1)) { File.Delete(file1); } } comm1.Update(ds1); } Response.Redirect(Request.PathInfo, true); }
void Repeater3_ItemCommand(object source, RepeaterCommandEventArgs e) { String id = e.CommandArgument.ToString(); if (String.IsNullOrEmpty(id) == false) { CommTable com1 = new CommTable("DA_AJDZFile"); List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("id", id, JSJ.SysFrame.SearchFieldType.数值型)); DataSet ds1 = com1.SearchData("*", condition); if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { DataRow dr1 = ds1.Tables[0].Rows[0]; String fileName = dr1["ajTrueFile"].ToString(); if (String.IsNullOrEmpty(fileName) == false) { fileName = Server.MapPath("../Common/AttachFiles/" + fileName); if (System.IO.File.Exists(fileName)) { System.IO.File.Delete(fileName); } } dr1.Delete(); com1.Update(ds1); } com1.Close(); this.BindData(); } }
/// <summary> /// 写入用户的登录日志 /// </summary> /// <param name="userid"></param> private void WirteLoginInfo(String userid) { CommTable com1 = new CommTable(); com1.TabName = "UserLogin"; List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("UserName", userid)); DataSet ds1 = com1.SearchData("*", condition); DataRow dr = null; DateTime now1 = DateTime.Now; if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { dr = ds1.Tables[0].Rows[0]; if (now1.Year.ToString() == dr["year1"].ToString().Trim() && now1.Month.ToString() == dr["month1"].ToString().Trim() && now1.Day.ToString() == dr["day1"].ToString().Trim() ) { dr["loginCount"] = int.Parse(dr["loginCount"].ToString()) + 1; } else { dr["year1"] = now1.Year.ToString(); dr["month1"] = now1.Month.ToString(); dr["day1"] = now1.Day.ToString(); dr["loginCount"] = 1; } } else { dr = ds1.Tables[0].NewRow(); dr["UserName"] = userid; dr["year1"] = now1.Year.ToString(); dr["month1"] = now1.Month.ToString(); dr["day1"] = now1.Day.ToString(); dr["loginCount"] = 1; ds1.Tables[0].Rows.Add(dr); } com1.Update(ds1); com1.Close(); }
//提交借阅申请 public static String BorrorAnJuan(String ajnum, String time0, String borrow, String remark) { String result = String.Empty; if (String.IsNullOrEmpty(ajnum) == false && String.IsNullOrEmpty(time0) == false && String.IsNullOrEmpty(borrow) == false) { CommTable tab1 = new CommTable(); tab1.TabName = "DA_JyBill"; List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("ajnum", ajnum)); condition.Add(new SearchField("borrow", borrow)); condition.Add(new SearchField("time1 is null", "", SearchOperator.用户定义)); DataSet ds1 = tab1.SearchData("*", condition); if (ds1 != null) { if (ds1.Tables[0].Rows.Count == 0) { DataRow dr1 = ds1.Tables[0].NewRow(); dr1["ajnum"] = ajnum; dr1["time0"] = time0; dr1["borrow"] = borrow; dr1["remark"] = remark; dr1["status"] = "0"; ds1.Tables[0].Rows.Add(dr1); tab1.Update(ds1); tab1.Close(); } else { result = "错误:你已借阅过了,正等待管理员审批!"; } } } return(result); }
protected void Button1_Click(object sender, EventArgs e) { Hashtable ht = new Hashtable(); ht.Add("status1", this.status1.SelectedValue); ht.Add("status2", this.status2.SelectedValue); ht.Add("zcid", Request.QueryString["zcid"]); ht.Add("time0", DateTime.Now.ToString()); ht.Add("zeren", User.Identity.Name); if (this.remark.Text.Trim() != String.Empty) { ht.Add("remark", this.remark.Text); } else { ht.Add("remark", "无"); } ht.Add("czid", Request.QueryString["czid"]); ht.Add("kind", "2"); if (this.dotime.Text.Trim() != String.Empty) { ht.Add("dotime", this.dotime.Text); } CommTable comm1 = null; bool success = false; try { comm1 = new CommTable(); comm1.TableConnect.BeginTrans(); //新增U_ZCTC表中的数据 comm1.TabName = "U_ZCTC"; comm1.InsertData(ht); //更改U_ZC2中表的数据 String zcid = null; String zcbid = null; comm1.TabName = "U_ZC2"; List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("id", Request.QueryString["czid"])); DataSet ds1 = comm1.SearchData("id,zcid,zcbid,spresult,status1,status2,spdotime", condition); if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { DataRow dr1 = ds1.Tables[0].Rows[0]; zcid = dr1["zcid"].ToString().Trim(); zcbid = dr1["zcbid"].ToString().Trim(); dr1["spresult"] = this.spresult.SelectedValue; dr1["status1"] = this.status1.SelectedValue; dr1["status2"] = this.status2.SelectedValue; if (String.IsNullOrEmpty(this.dotime.Text.Trim()) == false) { dr1["spdotime"] = this.dotime.Text.Trim(); } comm1.Update(ds1); } //更新资产或资产包中的相关数据 if (String.IsNullOrEmpty(zcid) == false || String.IsNullOrEmpty(zcbid) == false) { condition.Clear(); //优先考虑资产包 if (String.IsNullOrEmpty(zcbid) == false) { comm1.TabName = "U_ZCBAO"; condition.Add(new SearchField("id", zcbid, SearchFieldType.数值型)); } else { comm1.TabName = "U_ZC"; condition.Add(new SearchField("id", zcid, SearchFieldType.数值型)); } DataSet ds2 = comm1.SearchData("id,spresult,status1,status2,spdotime", condition); if (ds2 != null && ds2.Tables[0].Rows.Count > 0) { DataRow dr2 = ds2.Tables[0].Rows[0]; dr2["spresult"] = this.spresult.SelectedValue; dr2["status1"] = this.status1.SelectedValue; dr2["status2"] = this.status2.SelectedValue; if (String.IsNullOrEmpty(this.dotime.Text.Trim()) == false) { dr2["spdotime"] = this.dotime.Text.Trim(); } comm1.Update(ds2); } } comm1.TableConnect.CommitTrans(); success = true; } catch (Exception err) { comm1.TableConnect.RollBackTrans(); } finally { comm1.Close(); } //更改数据后返回 if (success) { Response.Redirect("EditSbb.aspx?id=" + Request.QueryString["czid"] + "&menuIndex=6", true); } else { JSJ.SysFrame.Util.alert(this.Page, "提示:数据库事务处理失败,请重试!"); } }
//删除付款 private void DeletePay(String id) { List <SearchField> condition = new List <SearchField>(); CommTable com1 = new CommTable(); com1.TableConnect.BeginTrans(); try { com1.TabName = "CW_Pay"; condition.Add(new SearchField("id", id, SearchFieldType.数值型)); DataSet ds1 = com1.SearchData("*", condition); Hashtable fee = new Hashtable(); if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { DataRow dr1 = ds1.Tables[0].Rows[0]; String zcid = dr1["zcid"].ToString(); String checktime = dr1["checktime"].ToString().Trim(); for (int i = 1; i <= 20; i++) { string key1 = "fee" + i; double temp = 0; if (String.IsNullOrEmpty(dr1[key1].ToString().Trim()) == false) { temp = double.Parse(dr1[key1].ToString().Trim()); } fee.Add(key1, temp); } //删除付款凭证数据 dr1.Delete(); com1.Update(ds1); //如果付款凭证已审核,则调整相关资产的数据 if (String.IsNullOrEmpty(checktime) == false) { com1.TabName = "U_Zc3"; condition.Clear(); condition.Add(new SearchField("id", zcid, SearchFieldType.数值型)); DataSet ds2 = com1.SearchData("*", condition); if (ds2 != null && ds2.Tables[0].Rows.Count > 0) { DataRow dr2 = ds2.Tables[0].Rows[0]; foreach (DictionaryEntry item in fee) { if (0 != (double)item.Value) { dr2[item.Key.ToString()] = double.Parse(dr2[item.Key.ToString()].ToString()) - (double)item.Value; } } com1.Update(ds2); } } } com1.TableConnect.CommitTrans(); } catch (Exception err) { com1.TableConnect.RollBackTrans(); } finally { com1.Close(); } }
//删除资产包单据数据(收款) private void DeleteZcBaoBill(String id) { CommTable com1 = new CommTable(); com1.TableConnect.BeginTrans(); try { //1) 得到单据的信息 bool flag = false; com1.TabName = "CW_ShouKuan1"; List <SearchField> list1 = new List <SearchField>(); list1.Add(new SearchField("id", id, SearchFieldType.数值型)); DataSet ds1 = com1.SearchData("*", list1); double pbj = 0; double plx = 0; String bid = String.Empty; if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { DataRow dr1 = ds1.Tables[0].Rows[0]; if (dr1["checktime"].ToString().Trim() != String.Empty) { flag = true; //表示单据已经审核过了 } bid = dr1["bid"].ToString(); //计算审核过的本金和利息 if (dr1["pbj"] != DBNull.Value) { pbj = double.Parse(dr1["pbj"].ToString()); } if (dr1["plx"] != DBNull.Value) { plx = double.Parse(dr1["plx"].ToString()); } dr1.Delete(); com1.Update(ds1); //删除单据的数据 //2) 处理资产包的数据 if (flag && String.IsNullOrEmpty(bid) == false) { list1.Clear(); list1.Add(new SearchField("id", bid, SearchFieldType.数值型)); com1.TabName = "U_ZCBAO"; DataSet ds0 = com1.SearchData("*", list1); if (ds0 != null && ds0.Tables[0].Rows.Count > 0) { double bljsk = 0; if (ds0.Tables[0].Rows[0]["bljsk"] != DBNull.Value) { bljsk = double.Parse(ds0.Tables[0].Rows[0]["bljsk"].ToString()); } bljsk = bljsk - pbj - plx; ds0.Tables[0].Rows[0]["bljsk"] = bljsk; //更新资产包的数据 com1.Update(ds0); } } } com1.TableConnect.CommitTrans(); //提交事务处理 } catch (Exception err) { com1.TableConnect.RollBackTrans(); //取消事务处理 Util.alert(this.Page, "提示:删除单据操作失败,请重试!"); } finally { if (com1 != null) { com1.Close(); } } }
//删除资产包单据数据(收款) private void DeleteZcBaoBillForPay(String id) { CommTable com1 = new CommTable(); com1.TableConnect.BeginTrans(); string[] arr1 = new string[] { "fee1", "fee2", "fee3", "fee4", "fee5", "fee6", "fee7", "fee8", "fee9", "fee10", "fee11", "fee12" }; double[] fee = new double[arr1.Length]; try { //1) 得到单据的信息 bool flag = false; com1.TabName = "CW_Pay1"; List <SearchField> list1 = new List <SearchField>(); list1.Add(new SearchField("id", id, SearchFieldType.数值型)); DataSet ds1 = com1.SearchData("*", list1); double pbj = 0; double plx = 0; String bid = String.Empty; if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { DataRow dr1 = ds1.Tables[0].Rows[0]; if (dr1["checktime"].ToString().Trim() != String.Empty) { flag = true; //表示单据已经审核过了 } bid = dr1["bid"].ToString(); //计算审核过的支出费用 for (int i = 0; i < arr1.Length; i++) { if (dr1[arr1[i]] != DBNull.Value) { fee[i] = double.Parse(dr1[arr1[i]].ToString()); } } dr1.Delete(); com1.Update(ds1); //删除单据的数据 //2) 处理资产包的数据 if (flag && String.IsNullOrEmpty(bid) == false) { list1.Clear(); list1.Add(new SearchField("id", bid, SearchFieldType.数值型)); com1.TabName = "U_ZCBAO"; DataSet ds0 = com1.SearchData("*", list1); if (ds0 != null && ds0.Tables[0].Rows.Count > 0) { double bljzc = 0; double bljzc1 = 0; if (ds0.Tables[0].Rows[0]["bljzc"] != DBNull.Value) { bljzc = double.Parse(ds0.Tables[0].Rows[0]["bljzc"].ToString()); } for (int i = 0; i < arr1.Length; i++) { bljzc1 = bljzc1 + fee[i]; } ds0.Tables[0].Rows[0]["bljzc"] = bljzc - bljzc1; //更新资产包的数据 com1.Update(ds0); } } } com1.TableConnect.CommitTrans(); //提交事务处理 } catch (Exception err) { com1.TableConnect.RollBackTrans(); //取消事务处理 Util.alert(this.Page, "提示:删除单据操作失败,请重试!"); } finally { if (com1 != null) { com1.Close(); } } }