public static List <t_unit_goods> GetUnitGoodsListById(int id) { List <t_unit_goods> result = new List <t_unit_goods>(); string sql = @" select x1.* from t_unit_goods x1 left join t_goods x2 on x1.goods_id=x2.id where x1.status_code!=-1 {0} ; "; //select count(1) as goods_id,sum(x1.count + 0) AS count, convert(sum(x1.price * x1.count), UNSIGNED) as price,convert(sum(x1.sell_min_price * x1.count), UNSIGNED) as sell_min_price, convert(sum(x1.sell_max_price * x1.count), UNSIGNED) as sell_max_price from t_unit_goods x1 where x1.status_code != -1 { 0} using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon)) { string strWhere = ""; if (!string.IsNullOrEmpty(id.ToString()) && id != 0) { strWhere += " and x1.unit_id=" + id + ""; } sql = string.Format(sql, strWhere); sql_conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, sql_conn); DataSet ds = new DataSet(); MySqlDataAdapter adapter = new MySqlDataAdapter(cmd); adapter.Fill(ds); result = (List <t_unit_goods>)IListDataSet.DataSetToIList <t_unit_goods>(ds, 0); } return(result); }
public static t_unit GetModel(long id) { t_unit result = new t_unit(); string sql = @" select * from t_unit where status_code!=-1 {0} ; "; using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon)) { string strWhere = ""; if (!string.IsNullOrEmpty(id.ToString()) && id != 0) { strWhere += " and id= " + id + ""; } sql = string.Format(sql, strWhere); sql_conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, sql_conn); DataSet ds = new DataSet(); MySqlDataAdapter adapter = new MySqlDataAdapter(cmd); adapter.Fill(ds); result = (t_unit)IListDataSet.DataSetToIList <t_unit>(ds, 0)[0]; return(result); } }
public static List <t_unit_goods> GetGoodsByUnitID(int UnitID, ref string code) { List <t_unit_goods> result = new List <t_unit_goods>(); string sql = @" select * from t_unit where status_code!=-1 {0}; select * from t_unit_goods where status_code!=-1 {1} ; "; //select count(1) as goods_id,sum(x1.count + 0) AS count, convert(sum(x1.price * x1.count), UNSIGNED) as price,convert(sum(x1.sell_min_price * x1.count), UNSIGNED) as sell_min_price, convert(sum(x1.sell_max_price * x1.count), UNSIGNED) as sell_max_price from t_unit_goods x1 where x1.status_code != -1 { 0} using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon)) { string strWhere = ""; string strWhere2 = ""; if (!string.IsNullOrEmpty(UnitID.ToString()) && UnitID != 0) { strWhere += " and unit_id=" + UnitID + ""; strWhere2 += " and id=" + UnitID + ""; } sql = string.Format(sql, strWhere2, strWhere); sql_conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, sql_conn); DataSet ds = new DataSet(); MySqlDataAdapter adapter = new MySqlDataAdapter(cmd); adapter.Fill(ds); code = ((List <t_unit>)IListDataSet.DataSetToIList <t_unit>(ds, 0)).FirstOrDefault().code; result = (List <t_unit_goods>)IListDataSet.DataSetToIList <t_unit_goods>(ds, 1); return(result); } }
public static List <t_goods> GetGoodsListFromSql(string str) { List <t_goods> result = new List <t_goods>(); string sql = @" select * from t_goods where `status`=1 {0} limit 0,10; "; using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon)) { string strWhere = ""; if (!string.IsNullOrEmpty(str)) { strWhere += " and (goodsName like '%" + str + "%' or type like '%" + str + "%')"; } sql = string.Format(sql, strWhere); sql_conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, sql_conn); DataSet ds = new DataSet(); MySqlDataAdapter adapter = new MySqlDataAdapter(cmd); adapter.Fill(ds); result = (List <t_goods>)IListDataSet.DataSetToIList <t_goods>(ds, 0); return(result); } }
public static List <t_unit_goods_list> GetUnitGoodsListData(string unit_id, string goods_type, string goods_name, string MD5, decimal?min_price, decimal?max_price, int pageIndex, int pageSize, ref int total) { List <t_unit_goods_list> result = new List <t_unit_goods_list>(); string sql = @" select SQL_CALC_FOUND_ROWS x2.`code`,x2.unit_name,x3.goodsName ,x1.* from t_unit_goods_list x1 left join t_unit x2 on x1.unit_id=x2.id left join t_goods x3 on x1.goods_id=x3.id where x1.status_code!=-1 {0} order by x1.random_num asc limit @begin,@pagesize; SELECT FOUND_ROWS() as total;; "; using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon)) { string strWhere = ""; if (!string.IsNullOrEmpty(unit_id) && unit_id != "0") { strWhere += " and x1.unit_id=" + unit_id + ""; } if (!string.IsNullOrEmpty(goods_type)) { strWhere += " and (x3.type like '%" + goods_type + "%' or x3.topType like '%" + goods_type + "%')"; } if (!string.IsNullOrEmpty(MD5)) { strWhere += " and (x1.MD5_1 = '" + MD5 + "' or x1.MD5_2='" + MD5 + "' or x1.MD5_3='" + MD5 + "' or x1.MD5_4='" + MD5 + "' or x1.MD5_5='" + MD5 + "')"; } if (!string.IsNullOrEmpty(goods_name)) { strWhere += " and (x3.goods_name like '%" + goods_name + "%' or x1.goods_name_new like '%" + goods_name + "%')"; } if (min_price != null && min_price != 0) { } if (max_price != null && max_price != 0) { } sql = string.Format(sql, strWhere); sql_conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, sql_conn); DataSet ds = new DataSet(); cmd.Parameters.AddWithValue("@begin", (pageIndex - 1) * pageSize); cmd.Parameters.AddWithValue("@pagesize", pageSize); MySqlDataAdapter adapter = new MySqlDataAdapter(cmd); adapter.Fill(ds); result = (List <t_unit_goods_list>)IListDataSet.DataSetToIList <t_unit_goods_list>(ds, 0); total = int.Parse(ds.Tables[1].Rows[0][0].ToString()); return(result); } }
public static List <t_unit> GetList(int currentPage, int pagesize, string code, string unit_kind, string unit_name, string price, string status_code, ref int total) { List <t_unit> result = new List <t_unit>(); string sql = @" select SQL_CALC_FOUND_ROWS * from t_unit x1 left join (select unit_id, convert(count(1), UNSIGNED) as goods_count, convert(sum(count), UNSIGNED) as goods_num from t_unit_goods where status_code=1 group by unit_id)x2 on x1.id=x2.unit_id where x1.status_code!=-1 {0} order by x1.id limit @begin,@pagesize; SELECT FOUND_ROWS() as total; "; using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon)) { string strWhere = ""; if (!string.IsNullOrEmpty(code)) { strWhere += " and code like '%" + code + "%'"; } if (!string.IsNullOrEmpty(unit_kind)) { strWhere += " and unit_kind like'%" + unit_kind + "%'"; } if (!string.IsNullOrEmpty(unit_name)) { strWhere += " and unit_name like'%" + unit_name + "%'"; } if (!string.IsNullOrEmpty(price) && price != "0") { strWhere += " and price=" + price + ""; } //if (!string.IsNullOrEmpty(status_code)) //{ // strWhere += " and status_code='" + status_code + "'"; //} sql = string.Format(sql, strWhere); sql_conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, sql_conn); DataSet ds = new DataSet(); cmd.Parameters.AddWithValue("@begin", (currentPage - 1) * pagesize); cmd.Parameters.AddWithValue("@pagesize", pagesize); MySqlDataAdapter adapter = new MySqlDataAdapter(cmd); adapter.Fill(ds); total = int.Parse(ds.Tables[1].Rows[0][0].ToString()); result = (List <t_unit>)IListDataSet.DataSetToIList <t_unit>(ds, 0); return(result); } }
/// <summary> /// 获取相机序列化数据 /// </summary> /// <returns>反馈序列化数据</returns> private List <VM_Content> GetCameraInfo(CameraStatus flag, ref string test) { IList <VM_CameraParameters> camerList = new List <VM_CameraParameters>(); CamereBLL camereBLL = new CamereBLL(); DataSet ds = new DataSet(); ds = camereBLL.GetCameraList(""); camerList = IListDataSet.DataSetToIList <VM_CameraParameters>(ds, 0); //if (m_VoltageLevel == 0) //{ // camerList = camerList.Where(s => s.exposureMode == "0").ToList(); //} //else //{ // camerList = camerList.Where(s => s.exposureMode == m_VoltageLevel.ToString()).ToList(); //} camerList = camerList.Where(s => s.exposureMode == m_VoltageLevel.ToString()).ToList(); IList <VM_Content> camerList2 = new List <VM_Content>(); if (flag == CameraStatus.Start) { camerList2.Add(new VM_Content { startTag = "Y", isMulti = "N", illumination = "1", station = "heifei", CameraParameters = camerList }); } else if (flag == CameraStatus.Stop) { camerList2.Add(new VM_Content { startTag = "N", isMulti = "N", illumination = "1", station = "heifei", CameraParameters = camerList }); } else { camerList2.Add(new VM_Content { startTag = "N", isMulti = "N", illumination = "1", station = "heifei", CameraParameters = camerList }); } //序列化 var lists = Newtonsoft.Json.JsonConvert.SerializeObject(camerList2); test = lists.ToString(); //反序列化 //Newtonsoft.Json.JsonConvert.DeserializeObject<List<VM_Content>>(lists); return(null); }
public static List <t_goods> GetGoodsList(int currentPage, int pagesize, string type, string goodsName, string minPrice, string maxPrice, ref int total) { List <t_goods> result = new List <t_goods>(); string sql = @" select SQL_CALC_FOUND_ROWS * from t_goods where `status`=1 {0} order by id desc limit @begin,@pagesize; SELECT FOUND_ROWS() as total; "; using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon)) { string strWhere = ""; if (!string.IsNullOrEmpty(type)) { strWhere += " and (type like '%" + type + "%' or topType like '%" + type + "%')"; } if (!string.IsNullOrEmpty(goodsName)) { strWhere += " and goodsName like'%" + goodsName + "%'"; } if (!string.IsNullOrEmpty(minPrice)) { strWhere += " and minPrice>=" + minPrice + ""; } if (!string.IsNullOrEmpty(maxPrice)) { strWhere += " and minPrice<=" + maxPrice + ""; } sql = string.Format(sql, strWhere); sql_conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, sql_conn); DataSet ds = new DataSet(); cmd.Parameters.AddWithValue("@begin", (currentPage - 1) * pagesize); cmd.Parameters.AddWithValue("@pagesize", pagesize); MySqlDataAdapter adapter = new MySqlDataAdapter(cmd); adapter.Fill(ds); total = int.Parse(ds.Tables[1].Rows[0][0].ToString()); result = (List <t_goods>)IListDataSet.DataSetToIList <t_goods>(ds, 0); return(result); } }
public bool Save() { try { this.Cursor = System.Windows.Forms.Cursors.WaitCursor; bool flag = false; if (dsPermission == null) { CommonServices.ErrorTrace.SetErrorInfo(this.FindForm(), "该用户没有操作权限"); flag = true; } if (btnPermissionList == null) { CommonServices.ErrorTrace.SetErrorInfo(this.FindForm(), "该用户没有按钮控制权限"); flag = true; } if (flag) { return(false); } BLLFty.Create <PermissionBLL>().Update(IListDataSet.DataSetToIList <Permission>(dsPermission, 0).ToList(), btnPermissionList); //vStockOutBillDtlForPrintBindingSource.DataSource = BLLFty.Create<StockOutBillBLL>().GetStockOutBillDtlForPrint(hd.ID); //gvBillDtlForPrint.BestFitColumns(); clientFactory.DataPageRefresh <Permission>().OrderBy(o => o.SerialNo); CommonServices.ErrorTrace.SetSuccessfullyInfo(this.FindForm(), "保存成功"); return(true); } catch (Exception ex) { CommonServices.ErrorTrace.SetErrorInfo(this.FindForm(), ex.Message); return(false); } finally { this.Cursor = System.Windows.Forms.Cursors.Default; } }
public IList <VM_VoltageParam> GetVoltageDsToListInfo() { IList <VM_VoltageParam> lst = IListDataSet.DataSetToIList <VM_VoltageParam>(GetVoltageList(""), 0); return(lst); }