private void but_test03_Click(object sender, EventArgs e) { //CnasClientMethods cntm = new CnasClientMethods(); int bl1 = CnasClientMethods.GetCondition(0, this.tb_04.Text); tb_03.Text = bl1.ToString(); }
public void SetPicData(string setbarCode) { if (!string.IsNullOrEmpty(setbarCode) && setbarCode.StartsWith("BCC")) { Image image = ((System.Drawing.Image)((new ComponentResourceManager(GetType())).GetObject("IconHorizontal"))); SortedList sortedList = new SortedList(); sortedList.Add(1, setbarCode); sortedList.Add(2, "1"); CnasRemotCall remoteClient = new CnasRemotCall(); string testSql = remoteClient.RemotInterface.CheckSelectData("HCS-image-sec002", sortedList); DataTable dtImageList = remoteClient.RemotInterface.SelectData("HCS-image-sec002", sortedList); if (dtImageList != null && dtImageList.Rows != null && dtImageList.Rows.Count > 0) { string fileName = ""; if (dtImageList.Rows[0]["data_url"] != null) { fileName = dtImageList.Rows[0]["data_url"].ToString(); } if (!string.IsNullOrEmpty(fileName)) { CnasClientMethods clientMethod = new CnasClientMethods(); System.IO.MemoryStream imageStream = clientMethod.Download(CnasBaseData.FTP_User, CnasBaseData.FTP_PWD, fileName, CnasBaseData.FTP_Path + "set/"); if (imageStream != null) { image = System.Drawing.Image.FromStream(imageStream); imageStream.Close(); } } } pic_data.Image = image; } }
private void but_test_Click(object sender, EventArgs e) { //#$set_type$# = 1 and CompareStr("#$washing_type$#","1")>0 string str_condition = rtb_condition.Text.Trim(), str_newcondition = ""; if (str_condition.Length == 0) { return; } string[] strarr01 = str_condition.Split(new string[] { "#$" }, StringSplitOptions.None); for (int i = 0; i < strarr01.Length; i++) { if (strarr01[i].IndexOf("$#", 0) > -1) { string[] strarr02 = strarr01[i].Split(new string[] { "$#" }, StringSplitOptions.None); str_newcondition = str_newcondition + "1" + strarr02[1]; } else { str_newcondition = str_newcondition + strarr01[i]; } } int int_rec = CnasClientMethods.GetCondition(0, str_newcondition); if (int_rec < 3) { but_savcon_Click(null, null); } else { MessageBox.Show("对不起!条件格式不正确,请仔细检查。"); } }
private void but_save_Click(object sender, EventArgs e) { try { if (this.dgv_imageList.Rows.Count <= 0) { return; //没有数据则不保存 } int sumnum = 0; //测试是否每张照片都添加成功 //有几张照片则保存几遍 for (int i = 0; i < this.dgv_imageList.Rows.Count; i++) { //上传到FTP文件夹的名称 string folderName = ""; int upType = Convert.ToInt32(Sl_Parameter["type"]); //包图片名称 string dataUrl = System.IO.Path.GetFileName(dgv_imageList.Rows[i].Cells[2].Value.ToString()); // 确定上传图片的类型 // 1-包 2-器械 if (upType == 1) { folderName = "set/"; } else if (upType == 2) { folderName = "instruments/"; } else if (upType == 3) { folderName = "safetyTimeReport/"; } #region 保存对应条码包的照片 //ftp: test.cnasis.cn:cnasftp:ftp123 //tsm_view_Click(null, null); //加载图片 BitmapData = new System.Drawing.Bitmap(this.dgv_imageList.Rows[i].Cells["data_url"].Value.ToString()); FileInfo fi = new FileInfo(this.dgv_imageList.Rows[i].Cells["data_url"].Value.ToString()); long logosize = fi.Length; if (logosize > 512000)//大于500kb则不保存 { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("bigimage", EnumPromptMessage.warning, new string[] { (i + 1).ToString() }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.pic_design.Image = BitmapData; this.pic_design.Width = BitmapData.Width; this.pic_design.Height = BitmapData.Height; Bitmap _NewBitmap = new Bitmap(this.pic_design.Width, pic_design.Height); //_NewBitmap.SetResolution(203, 203); pic_design.DrawToBitmap(_NewBitmap, new Rectangle(0, 0, _NewBitmap.Width, _NewBitmap.Height)); MemoryStream memStream = new MemoryStream(); _NewBitmap.Save(memStream, ImageFormat.Jpeg); CnasClientMethods CnasClientMethods01 = new CnasClientMethods(); CnasRemotCall reCnasRemotCall1 = new CnasRemotCall(); string objectName = reCnasRemotCall1.RemotInterface.Get_SerialNumber(2) + ".jpg"; ImageData01.Name = objectName; ImageCache imageCache = new ImageCache(); //保存图片 bool result = imageCache.SaveImageCache(folderName, objectName, memStream); if (!result) { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("errorimage", EnumPromptMessage.error, new string[] { "系统错误" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion //获取图片 Image picViewImage = imageCache.GetImageByFolderNameFileName(folderName, objectName); //返回不等于""说明有错误信息返回,弹出提示 if (picViewImage == null) { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("errorseeim", EnumPromptMessage.error, new string[] { "" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { this.pic_design.Image = picViewImage; } //rexxie通过条形码更新数据库:关联文件名 CnasRemotCall reCnasRemotCall = new CnasRemotCall(); SortedList sltmp = new SortedList(); SortedList sltmp01 = new SortedList(); //图片存储类型 sltmp.Add(1, upType); //包ID sltmp.Add(2, Sl_Parameter["pack_id"]); //包条码 sltmp.Add(3, Sl_Parameter["pack_barcode"]); //图片名称 sltmp.Add(4, objectName); //状态默认可用 sltmp.Add(5, 1); sltmp01.Add(1, sltmp); //string gg = reCnasRemotCall.RemotInterface.CheckUPData(1, "HCS_image-data-add001", sltmp01, null); int recint = reCnasRemotCall.RemotInterface.UPData(1, "HCS_image-data-add001", sltmp01, null); if (recint > -1) { sumnum++; } } if (sumnum == this.dgv_imageList.Rows.Count) { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("addsuccessful", EnumPromptMessage.warning, new string[] { "照片" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception ex) { MessageBox.Show("系统出现错误:" + ex.Message + "请联系管理员。"); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void but_OK_Click(object sender, EventArgs e) { CnasRemotCall reCnasRemotCall = new CnasRemotCall(); SortedList customerid = new SortedList(); customerid.Add(1, sl_customer.GetKey(sl_customer.IndexOfValue(cb_customer.Text.Trim())).ToString()); DataTable User = reCnasRemotCall.RemotInterface.SelectData("HCS-user-sec0011", customerid); if (string.IsNullOrEmpty(tb_name.Text) || string.IsNullOrEmpty(tb_name.Text.Trim()) || string.IsNullOrEmpty(tb_nick.Text) || string.IsNullOrEmpty(tb_nick.Text.Trim()) || string.IsNullOrEmpty(cb_sex.Text) || string.IsNullOrEmpty(cb_sex.Text.Trim()) || string.IsNullOrEmpty(cb_usertype.Text) || string.IsNullOrEmpty(cb_usertype.Text.Trim())) { MessageBox.Show("对不起!请仔细查看填写内容!!!!"); return; } if (string.IsNullOrEmpty(cb_location.Text) || string.IsNullOrEmpty(cb_location.Text.Trim())) { MessageBox.Show("请分配使用地点。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrEmpty(cb_customer.Text) || string.IsNullOrEmpty(cb_customer.Text.Trim())) { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("fillcustomer", EnumPromptMessage.warning), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrEmpty(cb_department.Text) || string.IsNullOrEmpty(cb_department.Text.Trim())) { MessageBox.Show("请选择部门。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (sl_user == null) //insert data { if (string.IsNullOrEmpty(tb_pwd.Text) || string.IsNullOrEmpty(tb_pwd.Text.Trim())) { MessageBox.Show("请填写密码。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (User != null) { int ii = User.Rows.Count; if (ii > 0) { for (int i = 0; i < ii; i++) { if (User.Rows[i]["user_name"].ToString().Trim() != null) { if (tb_name.Text.Trim().ToString() == User.Rows[i]["user_name"].ToString().Trim()) { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("namerepetition", EnumPromptMessage.warning, new string[] { "用户登录名" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } } } //if (UserBaseHelper.UserInfoByUserName(tb_name.Text.Trim()) != null)//判断是否同名 //{ // MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("usernameRepetition", EnumPromptMessage.warning), "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} SortedList sltmp = new SortedList(); SortedList sltmp01 = new SortedList(); sltmp01.Add(1, tb_name.Text.Trim()); sltmp01.Add(2, tb_code.Text.Trim()); sltmp01.Add(3, tb_eid.Text.Trim()); sltmp01.Add(4, tb_nick.Text.Trim()); sltmp01.Add(5, CnasClientMethods.GetMD5Hash(tb_pwd.Text.Trim())); sltmp01.Add(6, cb_sex.Text.Trim()); sltmp01.Add(7, tb_age.Text.Trim()); sltmp01.Add(8, CnasBaseData.SystemID); sltmp01.Add(9, cb_usertype.Text.Substring(0, 1)); sltmp01.Add(10, sl_location.GetKey(sl_location.IndexOfValue(cb_location.Text.Trim())).ToString()); sltmp01.Add(11, sl_customer.GetKey(sl_customer.IndexOfValue(cb_customer.Text.Trim())).ToString()); sltmp01.Add(12, sl_department.GetKey(sl_department.IndexOfValue(cb_department.Text.Trim())).ToString()); sltmp01.Add(13, pictureName); sltmp01.Add(14, tb_name.Text.Trim()); sltmp.Add(1, sltmp01); string strtmp = reCnasRemotCall.RemotInterface.CheckUPData(1, "HCS-userdata-add001", sltmp, null); int recint = reCnasRemotCall.RemotInterface.UPData(1, "HCS-userdata-add001", sltmp, null); if (recint > -1) { MessageBox.Show("恭喜你,增加用户成功。"); UploadUserImage(); this.Close(); } } else // update data { //判断用户是否有修改用户名称 if (tb_name.Text.Trim() != UserName) { if (User != null) { int ii = User.Rows.Count; if (ii > 0) { for (int i = 0; i < ii; i++) { if (User.Rows[i]["user_name"].ToString().Trim() != null) { if (tb_name.Text.Trim().ToString() == User.Rows[i]["user_name"].ToString().Trim()) { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("namerepetition", EnumPromptMessage.warning, new string[] { "用户登录名" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } } } } //update ca_user set user_name='?', user_eid='?',user_nick='?',user_pwd='?',sex='?',age='?',user_type=?,mod_date=now() where id=?; SortedList sltmp = new SortedList(); SortedList sltmp01 = new SortedList(); int recint = -1; if (tb_pwd.Text.Trim() == "") //不需要修改密码 { sltmp01.Add(1, tb_name.Text.Trim()); sltmp01.Add(2, tb_eid.Text.Trim()); sltmp01.Add(3, tb_nick.Text.Trim()); sltmp01.Add(4, cb_sex.Text.Trim()); sltmp01.Add(5, tb_age.Text.Trim()); sltmp01.Add(6, cb_usertype.Text.Substring(0, 1)); sltmp01.Add(7, sl_location.GetKey(sl_location.IndexOfValue(cb_location.Text.Trim())).ToString()); sltmp01.Add(8, sl_customer.GetKey(sl_customer.IndexOfValue(cb_customer.Text.Trim())).ToString()); sltmp01.Add(9, sl_department.GetKey(sl_department.IndexOfValue(cb_department.Text.Trim())).ToString()); sltmp01.Add(10, pictureName); sltmp01.Add(11, Strselectid); sltmp.Add(1, sltmp01); //CnasRemotCall reCnasRemotCall = new CnasRemotCall(); //string strtmp = reCnasRemotCall.RemotInterface.CheckUPData(1, "HCS-userdata-up001", sltmp, null); recint = reCnasRemotCall.RemotInterface.UPData(1, "HCS-userdata-up002", sltmp, null); } else //需要修改密码 { if (tb_pwd.Text.Trim().Length < 4) { MessageBox.Show("对不起!用户密码必须大于四位。"); return; } sltmp01.Add(1, tb_name.Text.Trim()); sltmp01.Add(2, tb_eid.Text.Trim()); sltmp01.Add(3, tb_nick.Text.Trim()); sltmp01.Add(4, CnasClientMethods.GetMD5Hash(tb_pwd.Text.Trim())); sltmp01.Add(5, cb_sex.Text.Trim()); sltmp01.Add(6, tb_age.Text.Trim()); sltmp01.Add(7, cb_usertype.Text.Substring(0, 1)); sltmp01.Add(8, sl_location.GetKey(sl_location.IndexOfValue(cb_location.Text.Trim())).ToString()); sltmp01.Add(9, sl_customer.GetKey(sl_customer.IndexOfValue(cb_customer.Text.Trim())).ToString()); sltmp01.Add(10, sl_department.GetKey(sl_department.IndexOfValue(cb_department.Text.Trim())).ToString()); sltmp01.Add(11, pictureName); sltmp01.Add(12, Strselectid); sltmp.Add(1, sltmp01); //string strtmp = reCnasRemotCall.RemotInterface.CheckUPData(1, "HCS-userdata-up001", sltmp, null); recint = reCnasRemotCall.RemotInterface.UPData(1, "HCS-userdata-up001", sltmp, null); } if (recint > -1) { MessageBox.Show("恭喜你,修改用户成功。"); UploadUserImage(); this.Close(); } } }