/// <summary> /// 向数据表Table_CAR_QSM更新一条记录。 /// </summary> /// <param name="QSMDAL">Table_CAR_QSM</param> /// <returns>影响的行数</returns> public int Update(QSMInfo qsminfo) { // Validate input if (qsminfo == null) { return(0); } return(qsmDal.Update(qsminfo)); }
/// <summary> /// 向数据库中插入一条新记录。 /// </summary> /// <param name="Table_CAR_QSM">qsminfo对象</param> /// <returns>新插入记录的编号</returns> public int add(QSMInfo qsminfo) { // Validate input if (qsminfo == null) { return(0); } return(qsmDal.Add(qsminfo)); }
///<sumary> /// 删除 ///</sumary> /// <param name="qsminfo">对象</param> ///<returns>返回INT类型号, 0为操作成功, 非0操作失败.</returns> public int Delete(QSMInfo qsminfo) { #region string sql = "sp_TABLE_CAR_QSM_Delete"; //========================= SqlParameter[] parameters = { new SqlParameter("@returnID", SqlDbType.Int), new SqlParameter("@RKEY", SqlDbType.Int, 4) }; parameters[0].Value = 1; parameters[0].Direction = ParameterDirection.InputOutput; parameters[1].Value = qsminfo.RKEY; //========================= #endregion /// int result = 0; #region try { dbHelper.ExecuteCommandProc(sql, parameters); result = int.Parse(parameters[0].Value.ToString()); } catch (Exception e) { result = 2; } finally { dbHelper.CloseConnection(); } #endregion return(result); }
protected void InitPage(QSMInfo info) { try { Serial_No.Text = info.SERIALNO.Trim(); CustName.Text = info.CUST_NAME.Trim(); FactoryName.Text = info.FACTORY_NAME; Happen_Date.Text = info.HAPPEN_DATE.ToString(); cust_MaterialNo.Text = info.CUST_MATERIALNO; interalNo.Text = info.INTERALNO; require_Date.Text = info.REQUIRE_DATE.ToString(); tousu_level.Text = info.TOUSU_LEVEL; tousu_type.Text = info.TOUSU_TYPE; CAR_Content.Text = Server.HtmlDecode(info.CAR_CONTENT); chuhuo_qty.Text = info.CHUHUO_QTY.ToString(); jiancha_qty.Text = info.JIANCHA_QTY.ToString(); buliang_qty.Text = info.BULIANG_QTY.ToString(); buliangbili.Text = info.BULIANGBILI.ToString() + "%"; buliangDC.Text = info.BULIANGDC; zaixian_qty.Text = info.ZAIXIAN_QTY.ToString(); kucun_qty.Text = info.KUCUN_QTY.ToString(); try { if (Convert.ToInt32(info.TUIHUO_STATUS) == 1) { tuihuo_status_ck1.Checked = false; tuihuo_status_ck2.Checked = true; tuihuo_qty.Text = info.TUIHUO_QTY.ToString(); } else if (Convert.ToInt32(info.TUIHUO_STATUS) == 0) { tuihuo_status_ck1.Checked = true; tuihuo_status_ck2.Checked = false; } happen_address.Items.FindByValue(info.HAPPEN_ADDRESS.ToString()).Selected = true; if (Convert.ToInt32(info.TIJIAO_STATUS.ToString()) == 1) { tijiao_status_ck1.Checked = false; tijiao_status_ck2.Checked = true; switch (Convert.ToInt32(info.TIJIAO_TYPE.ToString())) { case 1: tijiao_type_ck1.Checked = true; tijiao_type_ck2.Checked = false; tijiao_type_ck3.Checked = false; break; case 2: tijiao_type_ck1.Checked = false; tijiao_type_ck2.Checked = true; tijiao_type_ck3.Checked = false; break; case 3: tijiao_type_ck1.Checked = false; tijiao_type_ck2.Checked = false; tijiao_type_ck3.Checked = true; break; } } else { tijiao_status_ck1.Checked = true; tijiao_status_ck2.Checked = false; } } catch { } notes.Text = info.NOTES; dcjiaohuo_qty.Text = info.DCJIAOHUO_QTY.ToString(); try { if (Convert.ToInt32(info.ZAITU_STATUS) == 1) { zaitu_status_ck1.Checked = false; zaitu_status_ck2.Checked = true; zaitu_qty.Text = info.ZAITU_QTY.ToString(); } else { zaitu_status_ck1.Checked = true; zaitu_status_ck2.Checked = false; } switch (Convert.ToInt32(info.ZAITUCHULI_TYPE.ToString())) { case 1: chuli_status_ck1.Checked = true; chuli_status_ck2.Checked = false; chuli_status_ck3.Checked = false; break; case 2: chuli_status_ck1.Checked = false; chuli_status_ck2.Checked = true; chuli_status_ck3.Checked = false; break; case 3: chuli_status_ck1.Checked = false; chuli_status_ck2.Checked = false; chuli_status_ck3.Checked = true; break; } if (Convert.ToInt32(info.CANGCUN_STATUS) == 1) { changleikuchun_status_ck1.Checked = false; changleikuchun_status_ck2.Checked = true; } else { changleikuchun_status_ck1.Checked = true; changleikuchun_status_ck2.Checked = false; } switch (Convert.ToInt32(info.CANGCUNCHULI_TYPE.ToString())) { case 1: chuli_type_ck1.Checked = true; chuli_type_ck2.Checked = false; chuli_type_ck3.Checked = false; chuli_type_ck4.Checked = false; break; case 2: chuli_type_ck1.Checked = false; chuli_type_ck2.Checked = true; chuli_type_ck3.Checked = false; chuli_type_ck4.Checked = false; break; case 3: chuli_type_ck1.Checked = false; chuli_type_ck2.Checked = false; chuli_type_ck3.Checked = true; chuli_type_ck4.Checked = false; break; case 4: chuli_type_ck1.Checked = false; chuli_type_ck2.Checked = false; chuli_type_ck3.Checked = false; chuli_type_ck4.Checked = true; break; } } catch { } Info_Content.Text = Server.HtmlDecode(info.INFO_CONTENT); CONF_Content.Text = Server.HtmlDecode(info.CONF_CONTENT); } catch { } #region 文件路径 string id = System.Web.HttpContext.Current.User.Identity.Name.Replace("FOUNDERPCB\\", ""); id = id + @"/" + System.DateTime.Now.Date.ToShortDateString(); //Response.Write("id" + id); //建立用户目录 string path = Server.MapPath(@"uploads/" + id); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path);//在指定路径下新建一个文件夹 } CAR_Content.SetSecurityImageGalleryPath(path); CAR_Content.SetSecurityImageGalleryPath(path); CAR_Content.SetSecurityMediaGalleryPath(path); CAR_Content.SetSecurityFlashGalleryPath(path); CAR_Content.SetSecurityFilesGalleryPath(path); CONF_Content.SetSecurityImageGalleryPath(path); CONF_Content.SetSecurityImageGalleryPath(path); CONF_Content.SetSecurityMediaGalleryPath(path); CONF_Content.SetSecurityFlashGalleryPath(path); CONF_Content.SetSecurityFilesGalleryPath(path); #endregion }
/// <summary> /// 将信息写入库 /// </summary> private int Writedata(int status) { QSMBLL qsmbll = new QSMBLL(CurrentFactoryID); QSMInfo qsminfo = new QSMInfo(); if (did == 0) { qsminfo.RKEY = 0; qsminfo.SERIALNO = qsmbll.GetSerialNo(); } else { qsminfo = qsmbll.getQSMInfoByrkey(did); if (qsminfo.STATUS == 14) { string strTemp = qsminfo.SERIALNO; qsminfo = new QSMInfo(); qsminfo.RKEY = did; qsminfo.SERIALNO = strTemp; } } qsminfo.ENT_DATE = DateTime.Now; qsminfo.ENT_USER = CurrentUser.UserADAcount; qsminfo.CUST_CODE = CustCode.Value; qsminfo.CUST_NAME = CustName.Text; qsminfo.FACTORY_NAME = factoryList.SelectedItem.Text; try { qsminfo.HAPPEN_DATE = Convert.ToDateTime(Happen_Date.Text); } catch { qsminfo.HAPPEN_DATE = DateTime.Now; } qsminfo.CUST_MATERIALNO = cust_MaterialNo.Text; qsminfo.INTERALNO = interalNo.Text; try { qsminfo.REQUIRE_DATE = Convert.ToDateTime(require_Date.Text); } catch { } qsminfo.TOUSU_LEVEL = tousu_level.SelectedItem.Text; qsminfo.TOUSU_TYPE = tousu_type.SelectedItem.Text; try { qsminfo.CHUHUO_QTY = decimal.Parse(chuhuo_qty.Text); } catch { qsminfo.CHUHUO_QTY = 0; } try { qsminfo.JIANCHA_QTY = decimal.Parse(jiancha_qty.Text); } catch { qsminfo.JIANCHA_QTY = 0; } try { qsminfo.BULIANG_QTY = decimal.Parse(buliang_qty.Text); } catch { qsminfo.BULIANG_QTY = 0; } try { qsminfo.BULIANGBILI = decimal.Parse(buliangbili.Text.Trim().Replace("%", "")); } catch { qsminfo.BULIANGBILI = 0; } qsminfo.BULIANGDC = buliangDC.Text; try { qsminfo.ZAIXIAN_QTY = decimal.Parse(zaixian_qty.Text); } catch { qsminfo.ZAIXIAN_QTY = 0; } try { qsminfo.KUCUN_QTY = decimal.Parse(kucun_qty.Text); } catch { qsminfo.KUCUN_QTY = 0; } if (tuihuo_status_ck1.Checked == true) { qsminfo.TUIHUO_STATUS = 0; qsminfo.TUIHUO_QTY = 0; } else if (tuihuo_status_ck2.Checked == true) { qsminfo.TUIHUO_STATUS = 1; try { qsminfo.TUIHUO_QTY = decimal.Parse(tuihuo_qty.Text); } catch { qsminfo.TUIHUO_QTY = 0; } } qsminfo.HAPPEN_ADDRESS = int.Parse(happen_address.SelectedValue); if (tijiao_status_ck1.Checked == true) { qsminfo.TIJIAO_STATUS = 0; } else if (tijiao_status_ck2.Checked == true) { qsminfo.TIJIAO_STATUS = 1; if (tijiao_type_ck1.Checked == true) { qsminfo.TIJIAO_TYPE = 1; } else if (tijiao_type_ck2.Checked == true) { qsminfo.TIJIAO_TYPE = 2; } else if (tijiao_type_ck3.Checked == true) { qsminfo.TIJIAO_TYPE = 3; } } qsminfo.NOTES = notes.Text; qsminfo.CAR_CONTENT = CAR_Content.Text; qsminfo.STATUS = status; int a = 0; if (did == 0) { a = qsmbll.add(qsminfo); } else { a = qsmbll.Update(qsminfo); } if (a != 0) { return(-1); } return(int.Parse(qsminfo.RKEY.ToString())); }
/// <summary> /// 向数据库中插入一条新记录。 /// </summary> /// <param name="qsminfo">qsminfo对象</param> /// <returns>新插入记录的编号</returns> public int Add(QSMInfo qsminfo) { #region /// 调用SQL存储过程进行添加 string sql = "sp_TABLE_CAR_QSM_Add"; ///存储过程名 SqlParameter[] parameters = { new SqlParameter("@returnID", SqlDbType.Int), ///new SqlParameter("@rkey",SqlDbType.Int,4), new SqlParameter("@rkey", SqlDbType.Float), new SqlParameter("@serialNo", SqlDbType.VarChar, 20), new SqlParameter("@ent_Date", SqlDbType.DateTime, 8), new SqlParameter("@ent_user", SqlDbType.VarChar, 50), new SqlParameter("@tousu_level", SqlDbType.VarChar, 20), new SqlParameter("@tousu_type", SqlDbType.VarChar, 20), new SqlParameter("@cust_Code", SqlDbType.VarChar, 20), new SqlParameter("@cust_Name", SqlDbType.VarChar, 100), new SqlParameter("@factory_Name", SqlDbType.VarChar, 20), new SqlParameter("@happen_Date", SqlDbType.DateTime, 8), new SqlParameter("@cust_MaterialNo", SqlDbType.VarChar, 200), new SqlParameter("@interalNo", SqlDbType.VarChar, 50), new SqlParameter("@require_Date", SqlDbType.DateTime, 8), new SqlParameter("@CAR_Content", SqlDbType.VarChar, 8000), new SqlParameter("@chuhuo_qty", SqlDbType.Decimal, 9), new SqlParameter("@jiancha_qty", SqlDbType.Decimal, 9), new SqlParameter("@buliang_qty", SqlDbType.Decimal, 9), new SqlParameter("@buliangbili", SqlDbType.Decimal, 5), new SqlParameter("@buliangDC", SqlDbType.VarChar, 50), new SqlParameter("@zaixian_qty", SqlDbType.Decimal, 9), new SqlParameter("@kucun_qty", SqlDbType.Decimal, 9), new SqlParameter("@tuihuo_status", SqlDbType.Int, 4), new SqlParameter("@tuihuo_qty", SqlDbType.Decimal, 9), new SqlParameter("@happen_address", SqlDbType.Int, 4), new SqlParameter("@tijiao_status", SqlDbType.Int, 4), new SqlParameter("@tijiao_type", SqlDbType.Int, 4), new SqlParameter("@notes", SqlDbType.VarChar, 8000), new SqlParameter("@dcjiaohuo_qty", SqlDbType.Decimal, 9), new SqlParameter("@zaitu_status", SqlDbType.Int, 4), new SqlParameter("@zaitu_qty", SqlDbType.Decimal, 9), new SqlParameter("@zaituchuli_type", SqlDbType.Int, 4), new SqlParameter("@cangcun_status", SqlDbType.Int, 4), new SqlParameter("@cangcunchuli_type", SqlDbType.Int, 4), new SqlParameter("@info_content", SqlDbType.VarChar, 8000), new SqlParameter("@first_reply_date", SqlDbType.DateTime, 8), new SqlParameter("@last_reply_date", SqlDbType.DateTime, 8), new SqlParameter("@conf_content", SqlDbType.VarChar, 8000), new SqlParameter("@close_date", SqlDbType.DateTime, 8), new SqlParameter("@status", SqlDbType.Int, 4) }; parameters[0].Value = 0; parameters[0].Direction = ParameterDirection.InputOutput; parameters[1].Direction = ParameterDirection.InputOutput; parameters[1].Value = qsminfo.RKEY; parameters[2].Value = qsminfo.SERIALNO; parameters[3].Value = qsminfo.ENT_DATE; parameters[4].Value = qsminfo.ENT_USER; parameters[5].Value = qsminfo.TOUSU_LEVEL; parameters[6].Value = qsminfo.TOUSU_TYPE; parameters[7].Value = qsminfo.CUST_CODE; parameters[8].Value = qsminfo.CUST_NAME; parameters[9].Value = qsminfo.FACTORY_NAME; parameters[10].Value = qsminfo.HAPPEN_DATE; parameters[11].Value = qsminfo.CUST_MATERIALNO; parameters[12].Value = qsminfo.INTERALNO; parameters[13].Value = qsminfo.REQUIRE_DATE; parameters[14].Value = qsminfo.CAR_CONTENT; parameters[15].Value = qsminfo.CHUHUO_QTY; parameters[16].Value = qsminfo.JIANCHA_QTY; parameters[17].Value = qsminfo.BULIANG_QTY; parameters[18].Value = qsminfo.BULIANGBILI; parameters[19].Value = qsminfo.BULIANGDC; parameters[20].Value = qsminfo.ZAIXIAN_QTY; parameters[21].Value = qsminfo.KUCUN_QTY; parameters[22].Value = qsminfo.TUIHUO_STATUS; parameters[23].Value = qsminfo.TUIHUO_QTY; parameters[24].Value = qsminfo.HAPPEN_ADDRESS; parameters[25].Value = qsminfo.TIJIAO_STATUS; parameters[26].Value = qsminfo.TIJIAO_TYPE; parameters[27].Value = qsminfo.NOTES; parameters[28].Value = qsminfo.DCJIAOHUO_QTY; parameters[29].Value = qsminfo.ZAITU_STATUS; parameters[30].Value = qsminfo.ZAITU_QTY; parameters[31].Value = qsminfo.ZAITUCHULI_TYPE; parameters[32].Value = qsminfo.CANGCUN_STATUS; parameters[33].Value = qsminfo.CANGCUNCHULI_TYPE; parameters[34].Value = qsminfo.INFO_CONTENT; parameters[35].Value = qsminfo.FIRST_REPLY_DATE; parameters[36].Value = qsminfo.LAST_REPLY_DATE; parameters[37].Value = qsminfo.CONF_CONTENT; parameters[38].Value = qsminfo.CLOSE_DATE; parameters[39].Value = qsminfo.STATUS; #endregion /// int result = 0; #region 数据库操作 try { dbHelper.ExecuteCommandProc(sql, parameters); result = int.Parse(parameters[0].Value.ToString()); qsminfo.RKEY = int.Parse(parameters[1].Value.ToString()); } catch (Exception e) { ///message ID result = 2; } finally { dbHelper.CloseConnection(); } #endregion return(result); }
///<sumary> /// 通过SQL语句获取数据对象 ///</sumary> /// <param name="sqlWhere">sqlWhere参数条件</param> ///<returns>IList<qsminfo>数据集合</returns> public IList <QSMInfo> FindBySql(string sqlWhere) { #region SQL string sql = @"select isNull(rkey,0) as rkey , isNull(serialno,'') as serialno , ent_date , isNull(ent_user,'') as ent_user , isNull(tousu_level,'') as tousu_level , isNull(tousu_type,'') as tousu_type , isNull(cust_code,'') as cust_code , isNull(cust_name,'') as cust_name , isNull(factory_name,'') as factory_name , happen_date , isNull(cust_materialno,'') as cust_materialno , isNull(interalno,'') as interalno , require_date , isNull(car_content,'') as car_content , isNull(chuhuo_qty,0) as chuhuo_qty , isNull(jiancha_qty,0) as jiancha_qty , isNull(buliang_qty,0) as buliang_qty , isNull(buliangbili,0) as buliangbili , isNull(buliangdc,0) as buliangdc , isNull(zaixian_qty,0) as zaixian_qty , isNull(kucun_qty,0) as kucun_qty , isNull(tuihuo_status,0) as tuihuo_status , isNull(tuihuo_qty,0) as tuihuo_qty , isNull(happen_address,0) as happen_address , isNull(tijiao_status,0) as tijiao_status , isNull(tijiao_type,0) as tijiao_type , isNull(notes,'') as notes , isNull(dcjiaohuo_qty,0) as dcjiaohuo_qty , isNull(zaitu_status,0) as zaitu_status , isNull(zaitu_qty,0) as zaitu_qty , isNull(zaituchuli_type,0) as zaituchuli_type , isNull(cangcun_status,0) as cangcun_status , isNull(cangcunchuli_type,0) as cangcunchuli_type , isNull(info_content,'') as info_content , first_reply_date , last_reply_date , isNull(conf_content,'') as conf_content , close_date , isNull(status,0) as status from table_car_qsm" ; if (sqlWhere.Length > 0) { sql = sql + " where " + sqlWhere; } #endregion IList <QSMInfo> resultList = new List <QSMInfo>(); #region try { using (DataTable tb = dbHelper.GetDataSet(sql)) { foreach (DataRow row in tb.Rows) { QSMInfo qsminfo = new QSMInfo(); qsminfo.RKEY = int.Parse(row["rkey"].ToString()); qsminfo.SERIALNO = row["serialNo"].ToString(); if (row["ent_Date"].ToString() != "") { qsminfo.ENT_DATE = DateTime.Parse(row["ent_Date"].ToString()); } qsminfo.ENT_USER = row["ent_user"].ToString(); qsminfo.TOUSU_LEVEL = row["tousu_level"].ToString(); qsminfo.TOUSU_TYPE = row["tousu_type"].ToString(); qsminfo.CUST_CODE = row["cust_Code"].ToString(); qsminfo.CUST_NAME = row["cust_Name"].ToString(); qsminfo.FACTORY_NAME = row["factory_Name"].ToString(); if (row["happen_Date"].ToString() != "") { qsminfo.HAPPEN_DATE = DateTime.Parse(row["happen_Date"].ToString()); } qsminfo.CUST_MATERIALNO = row["cust_MaterialNo"].ToString(); qsminfo.INTERALNO = row["interalNo"].ToString(); if (row["require_Date"].ToString() != "") { qsminfo.REQUIRE_DATE = DateTime.Parse(row["require_Date"].ToString()); } qsminfo.CAR_CONTENT = row["CAR_Content"].ToString(); qsminfo.CHUHUO_QTY = decimal.Parse(row["chuhuo_qty"].ToString()); qsminfo.JIANCHA_QTY = decimal.Parse(row["jiancha_qty"].ToString()); qsminfo.BULIANG_QTY = decimal.Parse(row["buliang_qty"].ToString()); qsminfo.BULIANGBILI = decimal.Parse(row["buliangbili"].ToString()); qsminfo.BULIANGDC = row["buliangDC"].ToString(); qsminfo.ZAIXIAN_QTY = decimal.Parse(row["zaixian_qty"].ToString()); qsminfo.KUCUN_QTY = decimal.Parse(row["kucun_qty"].ToString()); qsminfo.TUIHUO_STATUS = int.Parse(row["tuihuo_status"].ToString()); qsminfo.TUIHUO_QTY = decimal.Parse(row["tuihuo_qty"].ToString()); qsminfo.HAPPEN_ADDRESS = int.Parse(row["happen_address"].ToString()); qsminfo.TIJIAO_STATUS = int.Parse(row["tijiao_status"].ToString()); qsminfo.TIJIAO_TYPE = int.Parse(row["tijiao_type"].ToString()); qsminfo.NOTES = row["notes"].ToString(); qsminfo.DCJIAOHUO_QTY = decimal.Parse(row["dcjiaohuo_qty"].ToString()); qsminfo.ZAITU_STATUS = int.Parse(row["zaitu_status"].ToString()); qsminfo.ZAITU_QTY = decimal.Parse(row["zaitu_qty"].ToString()); qsminfo.ZAITUCHULI_TYPE = int.Parse(row["zaituchuli_type"].ToString()); qsminfo.CANGCUN_STATUS = int.Parse(row["cangcun_status"].ToString()); qsminfo.CANGCUNCHULI_TYPE = int.Parse(row["cangcunchuli_type"].ToString()); qsminfo.INFO_CONTENT = row["info_content"].ToString(); if (row["first_reply_date"].ToString() != "") { qsminfo.FIRST_REPLY_DATE = DateTime.Parse(row["first_reply_date"].ToString()); } if (row["last_reply_date"].ToString() != "") { qsminfo.LAST_REPLY_DATE = DateTime.Parse(row["last_reply_date"].ToString()); } qsminfo.CONF_CONTENT = row["conf_content"].ToString(); if (row["close_date"].ToString() != "") { qsminfo.CLOSE_DATE = DateTime.Parse(row["close_date"].ToString()); } qsminfo.STATUS = int.Parse(row["status"].ToString()); resultList.Add(qsminfo); } } } catch (Exception e) { // Console.WriteLine(e.Message); throw e; } finally { dbHelper.CloseConnection(); } #endregion return(resultList); }