/// <summary> /// 非Soil图片入库 /// </summary> /// <param name="list_picname"></param> public static void InsertPicture(string[] list_picname) { byte[] buffer = Return_Buffer(); //string strSql = "insert into MONITOR_PICTURE(INDICATOR_NAME,CROP_CODE,MONITORTIME,PIC_MAP) values(@INDICATOR_NAME,@CROP_CODE,@MONITORTIME,@PIC_MAP)"; SqlConnection con = DataBaseOperate.getSqlCon(); SqlCommand cmd = new SqlCommand("insert_Picture", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@INDICATOR_NAME", list_picname[0]); cmd.Parameters.AddWithValue("@CROP_CODE", DataBaseOperate.getCrop_Code(list_picname[1])); cmd.Parameters.AddWithValue("@MONITORTIME", Convert.ToDateTime(list_picname[2]).ToShortDateString()); cmd.Parameters.AddWithValue("@PIC_MAP", buffer); cmd.ExecuteNonQuery(); }
private void btn_InDatabase_Click(object sender, EventArgs e) { int result = 0; string code2 = DataBaseOperate.getNUTRIENT_CODE(res[2]);//获取NUTRIENT_CODE string crop_code = DataBaseOperate.getCrop_Code(res[1]); for (int i = 1; i < dtInfo.Rows.Count - 1; i++) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@PLOTID", dtInfo.Rows[i]["地块编号"]), new SqlParameter("@MONITORTIME", dtInfo.Rows[i]["监测时间"]), new SqlParameter("@CROP_CODE", crop_code), new SqlParameter("@NUTRIENT_CODE", code2), new SqlParameter("@SOIL_NUTRIENT", dtInfo.Rows[i][5]), new SqlParameter("@RECORDTIME", DateTime.Now) }; result = DataBaseOperate.InsertDatabase("insert_Plot_SOILNUTRIENT", param); } if (result > 0) { MessageBox.Show("入库成功!"); } }
private void btn_InDatabase_Click(object sender, EventArgs e) { //判断入库的结果 int result = 0; //判断入库到那个表当中 switch (res[0]) { case "CROPYIELD": string code1 = DataBaseOperate.getCrop_Code(res[1]); //获取crop_Code for (int i = 1; i < dtInfo.Rows.Count - 1; i++) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@PLOTID", dtInfo.Rows[i]["地块编号"]), new SqlParameter("@MONITORTIME", dtInfo.Rows[i]["监测时间"]), new SqlParameter("@CROP_CODE", code1), new SqlParameter("@CROP_YIELD", dtInfo.Rows[i][5]), new SqlParameter("@RECORDTIME", DateTime.Now) }; result = DataBaseOperate.InsertDatabase("insert_Plot_CROPYIELD", param); } if (result > 0) { MessageBox.Show("入库成功!"); } break; case "MATUREPERIOD": string code3 = DataBaseOperate.getCrop_Code(res[1]); //获取crop_Code for (int i = 1; i < dtInfo.Rows.Count - 1; i++) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@PLOTID", dtInfo.Rows[i]["地块编号"]), new SqlParameter("@MONITORTIME", dtInfo.Rows[i]["监测时间"]), new SqlParameter("@CROP_CODE", code3), new SqlParameter("@MATURE_PERIOD", dtInfo.Rows[i][5]), new SqlParameter("@RECORDTIME", DateTime.Now) }; result = DataBaseOperate.InsertDatabase("insert_Plot_MATUREPERIOD", param); } if (result > 0) { MessageBox.Show("入库成功!"); } break; case "WATERRETRIEVAL": string code4 = DataBaseOperate.getCrop_Code(res[1]); //获取crop_Code for (int i = 1; i < dtInfo.Rows.Count - 1; i++) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@PLOTID", dtInfo.Rows[i]["地块编号"]), new SqlParameter("@MONITORTIME", dtInfo.Rows[i]["监测时间"]), new SqlParameter("@CROP_CODE", code4), new SqlParameter("@WATERVALUE", dtInfo.Rows[i][5]), new SqlParameter("@RECORDTIME", DateTime.Now) }; result = DataBaseOperate.InsertDatabase("insert_Plot_WATERRETRIEVAL", param); } if (result > 0) { MessageBox.Show("入库成功!"); } break; case "CHLOROPHYLLRETRIEVAL": string code5 = DataBaseOperate.getCrop_Code(res[1]); //获取crop_Code for (int i = 1; i < dtInfo.Rows.Count - 1; i++) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@PLOTID", dtInfo.Rows[i]["地块编号"]), new SqlParameter("@MONITORTIME", dtInfo.Rows[i]["监测时间"]), new SqlParameter("@CROP_CODE", code5), new SqlParameter("@CHLOROPHYLLVALUE", dtInfo.Rows[i][5]), new SqlParameter("@RECORDTIME", DateTime.Now) }; result = DataBaseOperate.InsertDatabase("insert_Plot_CHLOROPHYLLRETRIEVAL", param); } if (result > 0) { MessageBox.Show("入库成功!"); } break; } }