public bool DelUserByids(JSReader jsr) { var user = SystemUser.CurrentUser; string userid = user.UserID; using (DBConnection dbc = new DBConnection()) { dbc.BeginTransaction(); try { for (int i = 0; i < jsr.ToArray().Length; i++) { string str = "update tb_b_Users set User_DelFlag = 1,Updatetime=@Updatetime,Updateuser=@Updateuser where user_id =@user_id"; SqlCommand cmd = new SqlCommand(str); cmd.Parameters.AddWithValue("@Updatetime", DateTime.Now); cmd.Parameters.AddWithValue("@Updateuser", userid); cmd.Parameters.AddWithValue("@user_id", jsr.ToArray()[i].ToString()); dbc.ExecuteNonQuery(cmd); } dbc.CommitTransaction(); return(true); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }
public object Delete(string userid, JSReader jsr) { using (DBConnection dbc = new DBConnection()) { dbc.BeginTransaction(); try { JSReader[] js = jsr.ToArray(); SqlCommand cmd = new SqlCommand(); for (int i = 0; i < js.Length; i++) { cmd = new SqlCommand(); cmd.CommandText = @"delete from tb_b_User_LP_GL where UL_ID=@UL_ID"; cmd.Parameters.AddWithValue("@UL_ID", js[i].ToString()); dbc.ExecuteNonQuery(cmd); } dbc.CommitTransaction(); cmd = new SqlCommand(); cmd.CommandText = @"select UL_ID,a.lp_id,lp_name,lp_path,UL_PX from tb_b_User_LP_GL a left join tb_b_LeaderPage b on a.lp_id=b.lp_id where a.delflag=0 and a.User_ID='" + userid + "' order by UL_PX"; DataTable dt = dbc.ExecuteDataTable(cmd); return(dt); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }
public object SaveLP(string userid, JSReader jsr) { using (DBConnection dbc = new DBConnection()) { dbc.BeginTransaction(); try { JSReader[] js = jsr.ToArray(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = @"delete from tb_b_User_LP_GL where User_ID='" + userid + "'"; dbc.ExecuteNonQuery(cmd); for (int i = 0; i < js.Length; i++) { cmd = new SqlCommand(); cmd.CommandText = @"insert into tb_b_User_LP_GL select newid(),@userid,@lp_id,null,0,getdate(),getdate(),'9b628843-8ff6-4100-a7f9-73b4043871ad'"; cmd.Parameters.AddWithValue("@userid", userid); cmd.Parameters.AddWithValue("@lp_id", js[i].ToString()); dbc.ExecuteNonQuery(cmd); } dbc.CommitTransaction(); cmd = new SqlCommand(); cmd.CommandText = @"select UL_ID,a.lp_id,lp_name,lp_path,UL_PX from tb_b_User_LP_GL a left join tb_b_LeaderPage b on a.lp_id=b.lp_id where a.delflag=0 and a.User_ID='" + userid + "' order by UL_PX"; DataTable dt = dbc.ExecuteDataTable(cmd); return(dt); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }
public object DeleteJs(JSReader jsr) { var user = SystemUser.CurrentUser; string userid = user.UserID; string companyId = user.CompanyID; using (DBConnection dbc = new DBConnection()) { dbc.BeginTransaction(); try { for (int i = 0; i < jsr.ToArray().Length; i++) { //判断角色是否被用户关联就不能删除 string str = "select count(*) from tb_b_user_role where roleId=@roleId and companyId=@companyId"; SqlCommand ocmd = new SqlCommand(str); ocmd.Parameters.AddWithValue("@roleId", jsr.ToArray()[i].ToString()); ocmd.Parameters.AddWithValue("@companyId", companyId); int num = Convert.ToInt32(dbc.ExecuteScalar(ocmd)); if (num > 0) { throw new Exception("你所要删除的角色已经被用户关联,请先删除用户再进行此操作!"); } else { string delstr = "delete from tb_b_roledb where roleId=@roleId and companyId=@companyId"; ocmd = new SqlCommand(delstr); ocmd.Parameters.AddWithValue("roleId", jsr.ToArray()[i].ToString()); ocmd.Parameters.AddWithValue("companyId", companyId); dbc.ExecuteNonQuery(ocmd); } } dbc.CommitTransaction(); return(GetRole()); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }
public object DeleteJs(JSReader jsr, string zt) { var user = SystemUser.CurrentUser; string userid = user.UserID; using (DBConnection dbc = new DBConnection()) { dbc.BeginTransaction(); try { for (int i = 0; i < jsr.ToArray().Length; i++) { //判断角色是否被用户关联就不能删除 string str = "select count(*) from tb_b_User_JS_Gl where JS_ID=@JS_ID and delflag=0"; SqlCommand ocmd = new SqlCommand(str); ocmd.Parameters.AddWithValue("@JS_ID", jsr.ToArray()[i].ToString()); int num = Convert.ToInt32(dbc.ExecuteScalar(ocmd)); if (num > 0) { throw new Exception("你所要删除的角色已经被用户关联,请先删除用户再进行此操作!"); } else { string delstr = "update tb_b_JS set status=1,updatetime=@updatetime,updateuser=@updateuser where JS_ID=@JS_ID"; ocmd = new SqlCommand(delstr); ocmd.Parameters.AddWithValue("updatetime", DateTime.Now); ocmd.Parameters.AddWithValue("updateuser", userid); ocmd.Parameters.AddWithValue("JS_ID", jsr.ToArray()[i].ToString()); dbc.ExecuteNonQuery(ocmd); } } dbc.CommitTransaction(); return(GetJs(zt)); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }
public object DeleteRoomDevice(JSReader jsr) { using (DBConnection dbc = new DBConnection()) { dbc.BeginTransaction(); try { for (int i = 0; i < jsr.ToArray().Length; i++) { int ID = jsr.ToArray()[i].ToInteger(); dbc.ExecuteNonQuery("delete from Lock_Device where ID=" + ID); } dbc.CommitTransaction(); return(true); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }
public object DeleteHotel(JSReader jsr) { using (DBConnection dbc = new DBConnection()) { dbc.BeginTransaction(); try { for (int i = 0; i < jsr.ToArray().Length; i++) { int ID = jsr.ToArray()[i].ToInteger(); dbc.ExecuteNonQuery("delete from Lock_HotelApply where ID=" + ID + " and UserId=" + SystemUser.CurrentUser.UserID); dbc.ExecuteNonQuery("delete from Lock_HotelApply where HotelId=" + ID + " and UserId=" + SystemUser.CurrentUser.UserID); } dbc.CommitTransaction(); return(true); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }
public bool DelGoodsPrice(JSReader jsr) { using (MySqlDbConnection dbc = MySqlConnstr.GetDBConnection()) { dbc.BeginTransaction(); try { for (int i = 0; i < jsr.ToArray().Length; i++) { string sqlStr = "update tb_b_pricemodel set status=1 where id=" + dbc.ToSqlValue(jsr.ToArray()[i].ToString()); dbc.ExecuteDataTable(sqlStr); } dbc.CommitTransaction(); return(true); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }
public object SaveChildRoom(JSReader jsr, JSReader roomPic, JSReader goodsPic, int parentId, int hotelId, string roomGuid, JSReader tagIds, JSReader tagValues, string imgs) { using (DBConnection dbc = new DBConnection()) { dbc.BeginTransaction(); try { int RoomId; string ID = jsr["ID"].ToString(); int HotelId = hotelId; string RoomNo = jsr["RoomNo"].ToString(); int RoomCheckStatus = jsr["RoomCheckStatus"].ToInteger(); int RoomLiveStatus = jsr["RoomLiveStatus"].ToInteger(); int RoomStyleId; string RoomRemark = jsr["RoomRemark"].ToString().Trim(); string RoomAddress = jsr["RoomAddress"].ToString().Trim(); string RoomStyle = jsr["Name"].ToString().Trim(); DataTable dtRoomStyle = dbc.ExecuteDataTable("select * from Lock_RoomStyle where Name=" + dbc.ToSqlValue(RoomStyle)); if (dtRoomStyle.Rows.Count == 0) { RoomStyleId = Convert.ToInt16(dbc.ExecuteScalar("SELECT IDENT_CURRENT('Lock_RoomStyle') + IDENT_INCR('Lock_RoomStyle')").ToString()); var dtRS = dbc.GetEmptyDataTable("Lock_RoomStyle"); var drRS = dtRS.NewRow(); drRS["Name"] = RoomStyle; dtRS.Rows.Add(drRS); dbc.InsertTable(dtRS); } else { RoomStyleId = Convert.ToInt16(dtRoomStyle.Rows[0]["ID"].ToString()); } var dtRoom = dbc.GetEmptyDataTable("Lock_Room"); var drRoom = dtRoom.NewRow(); DataTableTracker dtt = new DataTableTracker(dtRoom); drRoom["ParentRoomId"] = parentId; drRoom["HotelId"] = HotelId; drRoom["RoomNo"] = RoomNo; drRoom["RoomCheckStatus"] = RoomCheckStatus; drRoom["RoomLiveStatus"] = RoomLiveStatus; drRoom["RoomKind"] = 2; drRoom["RoomStyleId"] = RoomStyleId; drRoom["RoomAddress"] = RoomAddress; drRoom["RoomRemark"] = RoomRemark; drRoom["IsContainSubRoom"] = 0; drRoom["GatewayStatus"] = 0; drRoom["SwitchStatus"] = 0; drRoom["LockStatus"] = 0; drRoom["IsClose"] = 0; drRoom["IsService"] = 1; drRoom["UserId"] = SystemUser.CurrentUser.UserID; drRoom["UserName"] = SystemUser.CurrentUser.UserName; //for (int i = 1; i < 6; i++) //{ // if (roomPic.ToArray().Length >= i) // drRoom["Image" + i] = roomPic.ToArray()[i - 1].ToString(); //} //for (int i = 1; i < 6; i++) //{ // if (goodsPic.ToArray().Length >= i) // drRoom["GoodsImage" + i] = goodsPic.ToArray()[i - 1].ToString(); //} if (!string.IsNullOrEmpty(imgs)) { string[] imglist = imgs.Split(new char[] { ',' }); for (int i = 1; i < 6; i++) { if (imglist.Count() >= i) { string newfilename = GetNewFilePath(imglist[i - 1], "~/files/Room/"); drRoom["Image" + i] = newfilename.Substring(2, newfilename.Length - 2); } else { drRoom["Image" + i] = ""; } } } else { for (int i = 1; i < 6; i++) { drRoom["Image" + i] = ""; } } if (ID == "") { int childCount = Convert.ToInt16(dbc.ExecuteScalar("select count(0) from Lock_Room where ParentRoomId=" + parentId)); drRoom["RoomSequence"] = childCount; drRoom["RoomGuid"] = roomGuid; drRoom["RoomGuidNumber"] = roomGuid + "" + childCount; drRoom["CreateDate"] = DateTime.Now; dtRoom.Rows.Add(drRoom); dbc.InsertTable(dtRoom); RoomId = Convert.ToInt16(dbc.ExecuteScalar("SELECT IDENT_CURRENT('Lock_Room') + IDENT_INCR('Lock_Room')").ToString()); } else { drRoom["ID"] = Convert.ToInt16(ID); drRoom["UpdateDate"] = DateTime.Now; dtRoom.Columns["ID"].ReadOnly = false; dtRoom.Rows.Add(drRoom); dbc.UpdateTable(dtRoom, dtt); dbc.ExecuteNonQuery("delete from Lock_RoomGoodsTag where RoomId=" + Convert.ToInt16(ID)); RoomId = Convert.ToInt16(ID); } for (int i = 0; i < tagIds.ToArray().Length; i++) { var dtRoomTag = dbc.GetEmptyDataTable("Lock_RoomGoodsTag"); var drRoomTag = dtRoomTag.NewRow(); drRoomTag["TagId"] = Convert.ToInt16(tagIds.ToArray()[i].ToString()); drRoomTag["RoomId"] = RoomId; drRoomTag["TagDec"] = tagValues.ToArray()[i]; dtRoomTag.Rows.Add(drRoomTag); dbc.InsertTable(dtRoomTag); } dbc.CommitTransaction(); return(true); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }
public object SaveHotel(JSReader jsr, JSReader file, JSReader tagIds, JSReader tagValues, string imgs) { using (DBConnection dbc = new DBConnection()) { dbc.BeginTransaction(); try { int HotelId; string ID = jsr["ID"].ToString(); string HotelName = jsr["HotelName"].ToString(); string HotelNo = jsr["HotelNo"].ToString(); string Mobile = jsr["Mobile"].ToString(); string Tel = jsr["Tel"].ToString(); string DetailAddress = jsr["DetailAddress"].ToString(); string Province = jsr["Province"].ToString(); string City = jsr["City"].ToString(); string County = jsr["County"].ToString(); string CompleteAddress = Province + City + County + DetailAddress; string Lat = jsr["Lat"].ToString(); string Lng = jsr["Lng"].ToString(); string ServiceInfo = jsr["ServiceInfo"].ToString(); int HourRoomTimeLong = 0; int HourRoomTimeLong2 = 0; int HourRoomTimeLong3 = 0; int CheckinHour = 0; int CheckinMinute = 0; int JudgeinHour = 0; int JudgeinMinute = 0; int CheckoutHour = 0; int CheckoutMinute = 0; float MonthRentPrice = 0; float DepositPriceByMonth = 0; int JSCycle = 0; string AlipayAccount = jsr["AlipayAccount"].ToString(); string LiableAccount = jsr["LiableAccount"].ToString(); string CleanerAccount = jsr["CleanerAccount"].ToString(); string DecRemark = jsr["DecRemark"].ToString(); string ConsumeRule = jsr["ConsumeRule"].ToString(); int IsHasWeekendPrice = jsr["IsHasWeekendPrice"].ToInteger(); int WeekendConatin5 = jsr["WeekendConatin5"].ToInteger(); int WeekendConatin6 = jsr["WeekendConatin6"].ToInteger(); int WeekendConatin7 = jsr["WeekendConatin7"].ToInteger(); int IsOpenDayRent = jsr["IsOpenDayRent"].ToInteger(); int IsOpenHourRent = jsr["IsOpenHourRent"].ToInteger(); int IsOpenMonthRent = jsr["IsOpenMonthRent"].ToInteger(); int ManagementMode = jsr["ManagementMode"].ToInteger(); int IsAutoAccept = jsr["IsAutoAccept"].ToInteger(); int HandlerKind = jsr["HandlerKind"].ToInteger(); int JsPlatSel = jsr["JsPlatSel"].ToInteger(); if (jsr["HourRoomTimeLong"].ToString() != "") { HourRoomTimeLong = jsr["HourRoomTimeLong"].ToInteger(); } if (jsr["HourRoomTimeLong2"].ToString() != "") { HourRoomTimeLong2 = jsr["HourRoomTimeLong2"].ToInteger(); } if (jsr["HourRoomTimeLong3"].ToString() != "") { HourRoomTimeLong3 = jsr["HourRoomTimeLong3"].ToInteger(); } if (jsr["CheckinHour"].ToString() != "") { CheckinHour = jsr["CheckinHour"].ToInteger(); } if (jsr["CheckinMinute"].ToString() != "") { CheckinMinute = jsr["CheckinMinute"].ToInteger(); } if (jsr["JudgeinHour"].ToString() != "") { JudgeinHour = jsr["JudgeinHour"].ToInteger(); } if (jsr["JudgeinMinute"].ToString() != "") { JudgeinMinute = jsr["JudgeinMinute"].ToInteger(); } if (jsr["CheckoutHour"].ToString() != "") { CheckoutHour = jsr["CheckoutHour"].ToInteger(); } if (jsr["CheckoutMinute"].ToString() != "") { CheckoutMinute = jsr["CheckoutMinute"].ToInteger(); } if (jsr["MonthRentPrice"].ToString() != "") { MonthRentPrice = jsr["MonthRentPrice"].ToSingle(); } if (jsr["DepositPriceByMonth"].ToString() != "") { DepositPriceByMonth = jsr["DepositPriceByMonth"].ToSingle(); } if (jsr["JSCycle"].ToString() != "") { JSCycle = jsr["JSCycle"].ToInteger(); } float DepositPrice = 0; if (jsr["DepositPrice"].ToString() != "") { DepositPrice = jsr["DepositPrice"].ToSingle(); } var dtHotel = dbc.GetEmptyDataTable("Lock_Hotel"); var drHotel = dtHotel.NewRow(); DataTableTracker dtt = new DataTableTracker(dtHotel); drHotel["HotelName"] = HotelName; drHotel["HotelNo"] = HotelNo; drHotel["Mobile"] = Mobile; drHotel["Tel"] = Tel; drHotel["DetailAddress"] = DetailAddress; drHotel["Province"] = Province; drHotel["City"] = City; drHotel["County"] = County; drHotel["CompleteAddress"] = CompleteAddress; drHotel["Lat"] = Lat; drHotel["Lng"] = Lng; drHotel["ServiceInfo"] = ServiceInfo; drHotel["HourRoomTimeLong"] = HourRoomTimeLong; drHotel["HourRoomTimeLong2"] = HourRoomTimeLong2; drHotel["HourRoomTimeLong3"] = HourRoomTimeLong3; drHotel["CheckinHour"] = CheckinHour; drHotel["CheckinMinute"] = CheckinMinute; drHotel["JudgeinHour"] = JudgeinHour; drHotel["JudgeinMinute"] = JudgeinMinute; drHotel["CheckoutHour"] = CheckoutHour; drHotel["CheckoutMinute"] = CheckoutMinute; drHotel["MonthRentPrice"] = MonthRentPrice; drHotel["JSCycle"] = JSCycle; drHotel["AlipayAccount"] = AlipayAccount; drHotel["LiableAccount"] = LiableAccount; drHotel["CleanerAccount"] = CleanerAccount; drHotel["DecRemark"] = DecRemark; drHotel["ConsumeRule"] = ConsumeRule; drHotel["IsHasWeekendPrice"] = IsHasWeekendPrice; drHotel["WeekendConatin5"] = WeekendConatin5; drHotel["WeekendConatin6"] = WeekendConatin6; drHotel["WeekendConatin7"] = WeekendConatin7; drHotel["IsOpenDayRent"] = IsOpenDayRent; drHotel["IsOpenHourRent"] = IsOpenHourRent; drHotel["IsOpenMonthRent"] = IsOpenMonthRent; drHotel["JsPlatSel"] = JsPlatSel; drHotel["DepositPrice"] = DepositPrice; drHotel["ManagementMode"] = ManagementMode; drHotel["IsAutoAccept"] = IsAutoAccept; drHotel["HandlerKind"] = HandlerKind; drHotel["DepositPriceByMonth"] = DepositPriceByMonth; drHotel["UserId"] = SystemUser.CurrentUser.UserID; drHotel["UserName"] = SystemUser.CurrentUser.UserName; //for (int i = 1; i < 6; i++) //{ // if (file.ToArray().Length >= i) // drHotel["Image" + i] = file.ToArray()[i - 1].ToString(); // else // drHotel["Image" + i] = ""; //} if (!string.IsNullOrEmpty(imgs)) { string[] imglist = imgs.Split(new char[] { ',' }); for (int i = 1; i < 6; i++) { if (imglist.Count() >= i) { string newfilename = GetNewFilePath(imglist[i - 1], "~/files/Hotel/"); drHotel["Image" + i] = newfilename.Substring(2, newfilename.Length - 2); } else { drHotel["Image" + i] = ""; } } } else { for (int i = 1; i < 6; i++) { drHotel["Image" + i] = ""; } } if (ID == "") { HotelId = Convert.ToInt16(dbc.ExecuteScalar("SELECT IDENT_CURRENT('Lock_Room') + IDENT_INCR('Lock_Room')").ToString()); drHotel["CreateDate"] = DateTime.Now; dtHotel.Rows.Add(drHotel); dbc.InsertTable(drHotel); } else { HotelId = Convert.ToInt16(ID); drHotel["ID"] = Convert.ToInt16(ID); drHotel["UpdateDate"] = DateTime.Now; dtHotel.Columns["ID"].ReadOnly = false; dtHotel.Rows.Add(drHotel); dbc.UpdateTable(dtHotel, dtt); } dbc.ExecuteNonQuery("delete from Lock_Tag where PID=" + HotelId + " and ZDLX=1"); DataTable dtTag = dbc.GetEmptyDataTable("Lock_Tag"); for (int i = 0; i < tagIds.ToArray().Length; i++) { DataRow drTag = dtTag.NewRow(); drTag["ZDBID"] = Convert.ToInt16(tagIds.ToArray()[i].ToString()); drTag["ZDLX"] = 1; drTag["VALUE"] = tagValues.ToArray()[i]; drTag["PID"] = HotelId; dtTag.Rows.Add(drTag); } dbc.InsertTable(dtTag); dbc.CommitTransaction(); return(true); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }
public static bool SaveKPALL(JSReader jsr, JSReader jsr2) { var companyId = SystemUser.CurrentUser.CompanyID; using (MySqlDbConnection dbc = MySqlConnstr.GetDBConnection()) { dbc.BeginTransaction(); try { for (int i = 0; i < jsr.ToArray().Length; i++) { string shippingnoteid = ""; string offerid = ""; string actualcompanypay = ""; string[] arr = jsr.ToArray()[i].ToString().Split(','); if (arr.Length > 0) { shippingnoteid = arr[0].ToString(); offerid = arr[1].ToString(); actualcompanypay = arr[2].ToString(); } var billingid = Guid.NewGuid().ToString(); var dt = dbc.GetEmptyDataTable("tb_b_invoice"); var dr = dt.NewRow(); dr["billingid"] = new Guid(billingid); dr["totalamount"] = actualcompanypay; dr["totalvaloremtax"] = actualcompanypay; dr["rate"] = jsr["rate"].ToString(); dr["billingtime"] = jsr["billingtime"].ToString(); dr["invoicecode"] = jsr["invoicecode"].ToString(); dr["invoicenumber"] = jsr["invoicenumber"].ToString(); dr["isdeleteflag"] = 0; dr["invoicestatus"] = 0; dt.Rows.Add(dr); dbc.InsertTable(dt); var dtde = dbc.GetEmptyDataTable("tb_b_invoicedetail"); var drde = dtde.NewRow(); drde["invoicedetailid"] = Guid.NewGuid().ToString(); drde["billingid"] = new Guid(billingid); drde["billingitem"] = jsr["billingitem"].ToString(); drde["amount"] = actualcompanypay; drde["shippingnoteid"] = shippingnoteid; drde["isdeleteflag"] = 0; dtde.Rows.Add(drde); dbc.InsertTable(dtde); var dtre = dbc.GetEmptyDataTable("tb_b_shippingnoteinfo_record"); var drre = dtre.NewRow(); drre["id"] = Guid.NewGuid().ToString(); drre["shippingnoteid"] = shippingnoteid; drre["recordtype"] = "开票"; drre["recordmemo"] = "开票时间:" + jsr["billingtime"].ToString() + ",票号:" + jsr["invoicenumber"].ToString() + ",金额:" + actualcompanypay + ",代码:" + jsr["invoicecode"].ToString(); drre["status"] = 0; drre["adduser"] = SystemUser.CurrentUser.UserID; drre["updateuser"] = SystemUser.CurrentUser.UserID; drre["addtime"] = DateTime.Now; drre["updatetime"] = DateTime.Now; dtre.Rows.Add(drre); dbc.InsertTable(dtre); } dbc.CommitTransaction(); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } return(true); }
public static bool HXMoneyALL(JSReader jsr, JSReader jsr2) { var companyId = SystemUser.CurrentUser.CompanyID; using (MySqlDbConnection dbc = MySqlConnstr.GetDBConnection()) { dbc.BeginTransaction(); try { for (int i = 0; i < jsr.ToArray().Length; i++) { string shippingnoteid = ""; string userid = ""; string offerid = ""; string actualdrivermoney = ""; string username = ""; string verifymoney = ""; string costid = ""; string[] arr = jsr.ToArray()[i].ToString().Split(','); if (arr.Length > 0) { shippingnoteid = arr[0].ToString(); userid = arr[1].ToString(); offerid = arr[2].ToString(); actualdrivermoney = arr[3].ToString(); if (arr[4].ToString() != null && arr[4].ToString() != "" && arr[4].ToString() != "null") { verifymoney = arr[4].ToString(); } else { verifymoney = "0"; } username = arr[5].ToString(); costid = arr[6].ToString(); } string ye = (Convert.ToDouble(actualdrivermoney) - Convert.ToDouble(verifymoney)).ToString(); if (ye == "0") { //dbc.ExecuteNonQuery("update tb_b_sourcegoodsinfo_offer set carrierverifystatus = 2,carrierverifymoney =" + dbc.ToSqlValue(actualdrivermoney) + " where offerid=" + dbc.ToSqlValue(offerid)); dbc.ExecuteNonQuery("update tb_b_shippingnoteinfo_cost set verifystatus = 2,verifymoney =" + dbc.ToSqlValue(actualdrivermoney) + " where id=" + dbc.ToSqlValue(costid)); } else { var dts = dbc.ExecuteDataTable("SELECT verifymoney,verifystatus FROM tb_b_shippingnoteinfo_cost WHERE id=" + dbc.ToSqlValue(costid)); if (dts.Rows.Count > 0) { if (dts.Rows[0][0] != null && dts.Rows[0][0].ToString() != "") { // dbc.ExecuteNonQuery("update tb_b_sourcegoodsinfo_offer set carrierverifystatus = 1,carrierverifymoney =carrierverifymoney+" + dbc.ToSqlValue(jsr["verifymoney"].ToString()) + " where offerid=" + dbc.ToSqlValue(offerid)); dbc.ExecuteNonQuery("update tb_b_shippingnoteinfo_cost set verifystatus = 1,verifymoney =verifymoney+" + dbc.ToSqlValue(jsr["verifymoney"].ToString()) + " where id=" + dbc.ToSqlValue(costid)); } else { // dbc.ExecuteNonQuery("update tb_b_sourcegoodsinfo_offer set carrierverifystatus = 1,carrierverifymoney =" + dbc.ToSqlValue(jsr["verifymoney"].ToString()) + " where offerid=" + dbc.ToSqlValue(offerid)); dbc.ExecuteNonQuery("update tb_b_shippingnoteinfo_cost set verifystatus = 1,verifymoney =" + dbc.ToSqlValue(jsr["verifymoney"].ToString()) + " where id=" + dbc.ToSqlValue(costid)); } } } //if (ye == "0") //{ // dbc.ExecuteNonQuery("update tb_b_sourcegoodsinfo_offer set carrierverifystatus = 2,carrierverifymoney =" + dbc.ToSqlValue(actualdrivermoney) + " where offerid=" + dbc.ToSqlValue(offerid)); //} //else //{ // var dts = dbc.ExecuteDataTable("SELECT carrierverifymoney,carrierverifystatus FROM tb_b_sourcegoodsinfo_offer WHERE offerid=" + dbc.ToSqlValue(offerid)); // if (dts.Rows.Count > 0) // { // if (dts.Rows[0][0] != null && dts.Rows[0][0].ToString() != "") // { // dbc.ExecuteNonQuery("update tb_b_sourcegoodsinfo_offer set carrierverifystatus = 1,carrierverifymoney =carrierverifymoney+" + dbc.ToSqlValue(ye) + " where offerid=" + dbc.ToSqlValue(offerid)); // } // else // { // dbc.ExecuteNonQuery("update tb_b_sourcegoodsinfo_offer set carrierverifystatus = 1,carrierverifymoney =" + dbc.ToSqlValue(ye) + " where offerid=" + dbc.ToSqlValue(offerid)); // } // } //} var dt = dbc.GetEmptyDataTable("tb_b_shippingnoteinfo_verify"); var dr = dt.NewRow(); dr["id"] = Guid.NewGuid().ToString(); dr["shippingnoteid"] = shippingnoteid; dr["costid"] = costid; dr["verifytype"] = 2;//司机核销 dr["verifymoney"] = ye; dr["verifypaytype"] = jsr2["verifypaytype"].ToString(); dr["verifytime"] = jsr2["verifytime"].ToString(); dr["userid"] = userid; dr["status"] = 0; dr["adduser"] = SystemUser.CurrentUser.UserID; dr["addtime"] = DateTime.Now; dr["updateuser"] = SystemUser.CurrentUser.UserID; dr["updatetime"] = DateTime.Now; dt.Rows.Add(dr); dbc.InsertTable(dt); var dt2 = dbc.GetEmptyDataTable("tb_b_shippingnoteinfo_record"); var dr2 = dt2.NewRow(); dr2["id"] = Guid.NewGuid().ToString(); dr2["shippingnoteid"] = shippingnoteid; dr2["recordtype"] = "财务核销"; dr2["recordmemo"] = SystemUser.CurrentUser.UserName + "在" + Convert.ToDateTime(jsr2["verifytime"].ToString()).ToString("yyyy-MM-dd") + ",财务核销" + username + ye + "元"; dr2["status"] = 0; dr2["adduser"] = SystemUser.CurrentUser.UserID; dr2["addtime"] = DateTime.Now; dr2["updateuser"] = SystemUser.CurrentUser.UserID; dr2["updatetime"] = DateTime.Now; dt2.Rows.Add(dr2); dbc.InsertTable(dt2); } dbc.CommitTransaction(); return(true); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }
public bool SaveUser(JSReader jsr, JSReader yhjs, JSReader yhjsdw, JSReader qxids) { if (jsr["LoginName"].IsNull || jsr["LoginName"].IsEmpty) { throw new Exception("用户名不能为空"); } if (jsr["Password"].IsNull || jsr["Password"].IsEmpty) { throw new Exception("密码不能为空"); } if (yhjs.ToArray().Length == 0) { throw new Exception("没有用户角色!"); } var EditUser = SystemUser.CurrentUser; using (DBConnection dbc = new DBConnection()) { dbc.BeginTransaction(); try { if (jsr["User_ID"].ToString() == "") { DataTable dt_user = dbc.ExecuteDataTable("select * from tb_b_Users where LoginName='" + jsr["LoginName"].ToString() + "' and User_DelFlag=0"); if (dt_user.Rows.Count > 0) { throw new Exception("该用户名已存在!"); } var YHID = Guid.NewGuid().ToString(); //建立用户 string sqlStr = ""; if (jsr["QY_ID"].ToString() != "") { sqlStr = "insert into tb_b_Users (User_ID,LoginName,Password,User_DM,User_XM,User_ZW,User_DH,User_SJ,User_Email,User_DZ,User_Enable,User_DelFlag,addtime,updatetime,updateuser,QY_ID) " + "values (@User_ID,@LoginName,@Password,@User_DM,@User_XM,@User_ZW,@User_DH,@User_SJ,@User_Email,@User_DZ,@User_Enable,@User_DelFlag,@addtime,@updatetime,@updateuser,@qyid)"; } else { sqlStr = "insert into tb_b_Users (User_ID,LoginName,Password,User_DM,User_XM,User_ZW,User_DH,User_SJ,User_Email,User_DZ,User_Enable,User_DelFlag,addtime,updatetime,updateuser) " + "values (@User_ID,@LoginName,@Password,@User_DM,@User_XM,@User_ZW,@User_DH,@User_SJ,@User_Email,@User_DZ,@User_Enable,@User_DelFlag,@addtime,@updatetime,@updateuser)"; } SqlCommand cmd = new SqlCommand(sqlStr); cmd.Parameters.AddWithValue("@User_ID", YHID); cmd.Parameters.AddWithValue("@LoginName", jsr["LoginName"].ToString()); cmd.Parameters.AddWithValue("@Password", jsr["Password"].ToString()); cmd.Parameters.AddWithValue("@User_DM", jsr["User_DM"].ToString()); cmd.Parameters.AddWithValue("@User_XM", jsr["User_XM"].ToString()); cmd.Parameters.AddWithValue("@User_ZW", jsr["User_ZW"].ToString()); cmd.Parameters.AddWithValue("@User_DH", jsr["User_DH"].ToString()); cmd.Parameters.AddWithValue("@User_SJ", jsr["User_SJ"].ToString()); cmd.Parameters.AddWithValue("@User_Email", jsr["User_Email"].ToString()); cmd.Parameters.AddWithValue("@User_DZ", jsr["User_DZ"].ToString()); if (jsr["QY_ID"].ToString() != "") { cmd.Parameters.AddWithValue("@qyid", jsr["QY_ID"].ToString()); } cmd.Parameters.AddWithValue("@User_Enable", Convert.ToInt32(jsr["User_Enable"].ToString())); cmd.Parameters.AddWithValue("@User_DelFlag", 0); cmd.Parameters.AddWithValue("@addtime", DateTime.Now); cmd.Parameters.AddWithValue("@updatetime", DateTime.Now); cmd.Parameters.AddWithValue("@updateuser", EditUser.UserID); dbc.ExecuteNonQuery(cmd); //建立用户角色关联 for (int i = 0; i < yhjs.ToArray().Length; i++) { string sqlstr_js = "insert into tb_b_User_JS_Gl (UserGl_id,User_ID,JS_ID,delflag,addtime,updatetime,updateuser) values(@UserGl_id,@User_ID,@JS_ID,@delflag,@addtime,@updatetime,@updateuser)"; cmd = new SqlCommand(sqlstr_js); cmd.Parameters.AddWithValue("@UserGl_id", Guid.NewGuid()); cmd.Parameters.AddWithValue("@User_ID", YHID); cmd.Parameters.AddWithValue("@JS_ID", yhjs.ToArray()[i].ToString()); cmd.Parameters.AddWithValue("@delflag", 0); cmd.Parameters.AddWithValue("@addtime", DateTime.Now); cmd.Parameters.AddWithValue("@updatetime", DateTime.Now); cmd.Parameters.AddWithValue("@updateuser", EditUser.UserID); dbc.ExecuteNonQuery(cmd); } //建立用户单位关联 for (int i = 0; i < yhjsdw.ToArray().Length; i++) { JSReader[] arr_dw = yhjsdw.ToArray()[i].ToArray(); for (int k = 0; k < arr_dw.Length; k++) { string sqlstr_dw = "insert into tb_b_User_Dw_Gl(UserDwGL_id,User_ID,DW_ID,delflag,addtime,updatetime,updateuser) values(@UserDwGL_id,@User_ID,@DW_ID,@delflag,@addtime,@updatetime,@updateuser)"; cmd = new SqlCommand(sqlstr_dw); cmd.Parameters.AddWithValue("@UserDwGL_id", Guid.NewGuid()); cmd.Parameters.AddWithValue("@User_ID", YHID); cmd.Parameters.AddWithValue("@DW_ID", arr_dw[k].ToString()); cmd.Parameters.AddWithValue("@delflag", 0); cmd.Parameters.AddWithValue("@addtime", DateTime.Now); cmd.Parameters.AddWithValue("@updatetime", DateTime.Now); cmd.Parameters.AddWithValue("@updateuser", EditUser.UserID); dbc.ExecuteNonQuery(cmd); } } //建立用户权限关联 for (int i = 0; i < qxids.ToArray().Length; i++) { string sqlstr_qx = "insert into tb_b_YH_YHQX (PRIVILEGECODE,USERID) values(@PRIVILEGECODE,@USERID)"; cmd = new SqlCommand(sqlstr_qx); cmd.Parameters.AddWithValue("@PRIVILEGECODE", new Guid(qxids.ToArray()[i])); cmd.Parameters.AddWithValue("@USERID", YHID); dbc.ExecuteNonQuery(cmd); } } else { var YHID = jsr["User_ID"].ToString(); var oldname = dbc.ExecuteScalar("select LoginName from tb_b_Users where User_ID='" + YHID + "'"); if (!jsr["LoginName"].ToString().Equals(oldname.ToString())) { DataTable dt_user = dbc.ExecuteDataTable("select * from tb_b_Users where LoginName='" + jsr["LoginName"].ToString() + "' and User_DelFlag=0"); if (dt_user.Rows.Count > 0) { throw new Exception("该用户名已存在!"); } } var con = ""; if (jsr["QY_ID"].ToString() != "") { con = ",QY_ID='" + jsr["QY_ID"].ToString() + "'"; } else { con = ",QY_ID=null"; } string sqlstr = "update tb_b_Users set LoginName=@LoginName,Password=@Password,User_DM=@User_DM,User_XM=@User_XM,User_ZW=@User_ZW,User_DH=@User_DH,User_SJ=@User_SJ,User_Email=@User_Email,User_DZ=@User_DZ,User_Enable=@User_Enable,updatetime=@updatetime,updateuser=@updateuser " + con + " where User_ID=@User_ID"; SqlCommand cmd = new SqlCommand(sqlstr); cmd.Parameters.AddWithValue("@LoginName", jsr["LoginName"].ToString()); cmd.Parameters.AddWithValue("@Password", jsr["Password"].ToString()); cmd.Parameters.AddWithValue("@User_DM", jsr["User_DM"].ToString()); cmd.Parameters.AddWithValue("@User_XM", jsr["User_XM"].ToString()); cmd.Parameters.AddWithValue("@User_ZW", jsr["User_ZW"].ToString()); cmd.Parameters.AddWithValue("@User_DH", jsr["User_DH"].ToString()); cmd.Parameters.AddWithValue("@User_SJ", jsr["User_SJ"].ToString()); cmd.Parameters.AddWithValue("@User_Email", jsr["User_Email"].ToString()); cmd.Parameters.AddWithValue("@User_DZ", jsr["User_DZ"].ToString()); cmd.Parameters.AddWithValue("@User_Enable", Convert.ToInt32(jsr["User_Enable"].ToString())); cmd.Parameters.AddWithValue("@updatetime", DateTime.Now); cmd.Parameters.AddWithValue("@updateuser", EditUser.UserID); cmd.Parameters.AddWithValue("@User_ID", YHID); dbc.ExecuteNonQuery(cmd); //删除用户的角色关联 string del_js = "update tb_b_User_JS_Gl set delflag=1,updatetime=@updatetime,updateuser=@updateuser where User_ID=@User_ID"; cmd = new SqlCommand(del_js); cmd.Parameters.AddWithValue("@updatetime", DateTime.Now); cmd.Parameters.AddWithValue("@updateuser", EditUser.UserID); cmd.Parameters.AddWithValue("@User_ID", YHID); dbc.ExecuteNonQuery(cmd); //删除用户的单位关联 string del_dw = "update tb_b_User_Dw_Gl set delflag=1,updatetime=@updatetime,updateuser=@updateuser where User_ID=@User_ID"; cmd = new SqlCommand(del_dw); cmd.Parameters.AddWithValue("@updatetime", DateTime.Now); cmd.Parameters.AddWithValue("@updateuser", EditUser.UserID); cmd.Parameters.AddWithValue("@User_ID", YHID); dbc.ExecuteNonQuery(cmd); //删除用户的权限关联 string del_qx = "delete from tb_b_YH_YHQX where USERID=@USERID"; cmd = new SqlCommand(del_qx); cmd.Parameters.AddWithValue("@USERID", YHID); dbc.ExecuteNonQuery(cmd); //建立用户角色关联 for (int i = 0; i < yhjs.ToArray().Length; i++) { string sqlstr_js = "insert into tb_b_User_JS_Gl (UserGl_id,User_ID,JS_ID,delflag,addtime,updatetime,updateuser) values(@UserGl_id,@User_ID,@JS_ID,@delflag,@addtime,@updatetime,@updateuser)"; cmd = new SqlCommand(sqlstr_js); cmd.Parameters.AddWithValue("@UserGl_id", Guid.NewGuid()); cmd.Parameters.AddWithValue("@User_ID", YHID); cmd.Parameters.AddWithValue("@JS_ID", yhjs.ToArray()[i].ToString()); cmd.Parameters.AddWithValue("@delflag", 0); cmd.Parameters.AddWithValue("@addtime", DateTime.Now); cmd.Parameters.AddWithValue("@updatetime", DateTime.Now); cmd.Parameters.AddWithValue("@updateuser", EditUser.UserID); dbc.ExecuteNonQuery(cmd); } //建立用户单位关联 for (int i = 0; i < yhjsdw.ToArray().Length; i++) { JSReader[] arr_dw = yhjsdw.ToArray()[i].ToArray(); for (int k = 0; k < arr_dw.Length; k++) { string sqlstr_dw = "insert into tb_b_User_Dw_Gl(UserDwGL_id,User_ID,DW_ID,delflag,addtime,updatetime,updateuser) values(@UserDwGL_id,@User_ID,@DW_ID,@delflag,@addtime,@updatetime,@updateuser)"; cmd = new SqlCommand(sqlstr_dw); cmd.Parameters.AddWithValue("@UserDwGL_id", Guid.NewGuid()); cmd.Parameters.AddWithValue("@User_ID", YHID); cmd.Parameters.AddWithValue("@DW_ID", arr_dw[k].ToString()); cmd.Parameters.AddWithValue("@delflag", 0); cmd.Parameters.AddWithValue("@addtime", DateTime.Now); cmd.Parameters.AddWithValue("@updatetime", DateTime.Now); cmd.Parameters.AddWithValue("@updateuser", EditUser.UserID); dbc.ExecuteNonQuery(cmd); } } //建立用户权限关联 for (int i = 0; i < qxids.ToArray().Length; i++) { string sqlstr_qx = "insert into tb_b_YH_YHQX (PRIVILEGECODE,USERID) values(@PRIVILEGECODE,@USERID)"; cmd = new SqlCommand(sqlstr_qx); cmd.Parameters.AddWithValue("@PRIVILEGECODE", new Guid(qxids.ToArray()[i])); cmd.Parameters.AddWithValue("@USERID", YHID); dbc.ExecuteNonQuery(cmd); } } dbc.CommitTransaction(); return(true); } catch (Exception ex) { dbc.RoolbackTransaction(); throw ex; } } }