private void _create_Click(object sender, RoutedEventArgs e) { if (_card_id.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入检疫证号!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } bool exit_flag = dbOperation.GetDbHelper().Exists(string.Format("SELECT count(productcardid) from t_certificate_product where productcardid ='{0}'", _card_id.Text)); if (exit_flag) { Toolkit.MessageBox.Show("检疫证号已存在,请重新输入!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_help_user.SelectedIndex < 1) { Toolkit.MessageBox.Show("请选择协检员!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_shipper_id.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入货主代码!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_product_name.SelectedIndex < 1) { Toolkit.MessageBox.Show("请选择产品名称!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_object_count.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入数量!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_dept_name.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入生产单位!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_cz_cardid.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入检疫标志号!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } string sql = string.Format("INSERT INTO t_certificate_product(productcardid,companyid,companyname," + "cardid,objectid,objectname,objectcount,productarea,deptname," + "deptarea,destinationarea,bz,createdeptid,createuserid,createdate,createloginid,helpuserid)" + " values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}'," + "'{10}','{11}','{12}','{13}','{14}','{15}','{16}')" , _card_id.Text, _shipper_id.Text, _shipper.Text, _cz_cardid.Text, (_product_name.SelectedItem as Label).Tag.ToString(), _product_name.Text, _object_count.Text + _object_type.Text, _dept_area.Text, _dept_name.Text, _dept_address.Text, _mdd.Text, _bz.Text, deptId, userId, System.DateTime.Now, loginid, (_help_user.SelectedItem as Label).Tag.ToString()); int i = dbOperation.GetDbHelper().ExecuteSql(sql); if (i >= 0) { List <string> cer_details = new List <string>() { _card_id.Text, _shipper.Text, _cz_cardid.Text, _product_name.Text, _object_count.Text, _object_type.Text, _dept_area.Text, _dept_name.Text, _dept_address.Text, _mdd.Text, _bz.Text, username, loginid, System.DateTime.Now.Year.ToString(), System.DateTime.Now.Month.ToString(), System.DateTime.Now.Day.ToString() }; UcCertificateProductDetails cer = new UcCertificateProductDetails(cer_details); //grid_info.Children.Add(cer); PrintDialog dialog = new PrintDialog(); //if (dialog.ShowDialog() == true) //{ dialog.PrintQueue = GetPrinter(); Size printSize = new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight); cer.Measure(printSize); cer.Arrange(new Rect(0, 0, dialog.PrintableAreaWidth, dialog.PrintableAreaHeight)); //Size printSize = new Size(793, 529); //cer.Measure(printSize); //cer.Arrange(new Rect(0, 0, 793, 529)); dialog.PrintVisual(cer, "产品检疫证"); //} //Toolkit.MessageBox.Show("电子出证单生成成功!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); clear(); return; } else { Toolkit.MessageBox.Show("电子出证单生成失败!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } }
private void _create_Click(object sender, RoutedEventArgs e) { if (_card_id.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入检疫证号!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } bool exit_flag = dbOperation.GetDbHelper().Exists(string.Format("SELECT count(productcardid) from t_certificate_product where productcardid ='{0}'", _card_id.Text)); if (exit_flag) { Toolkit.MessageBox.Show("检疫证号已存在,请重新输入!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_help_user.SelectedIndex < 1) { Toolkit.MessageBox.Show("请选择协检员!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_shipper_id.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入货主代码!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_product_name.SelectedIndex < 1) { Toolkit.MessageBox.Show("请选择产品名称!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_object_count.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入数量!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_dept_name.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入生产单位!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_cz_cardid.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入检疫标志号!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } string sql = string.Format("INSERT INTO t_certificate_product(productcardid,companyid,companyname," + "cardid,objectid,objectname,objectcount,productarea,deptname," + "deptarea,destinationarea,bz,createdeptid,createuserid,createdate,createloginid,helpuserid)" + " values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}'," + "'{10}','{11}','{12}','{13}','{14}','{15}','{16}')" ,_card_id.Text, _shipper_id.Text, _shipper.Text, _cz_cardid.Text, (_product_name.SelectedItem as Label).Tag.ToString(), _product_name.Text, _object_count.Text + _object_type.Text, _dept_area.Text, _dept_name.Text, _dept_address.Text, _mdd.Text, _bz.Text, deptId, userId, System.DateTime.Now, loginid,(_help_user.SelectedItem as Label).Tag.ToString()); int i = dbOperation.GetDbHelper().ExecuteSql(sql); if (i >= 0) { List<string> cer_details = new List<string>() {_card_id.Text,_shipper.Text,_cz_cardid.Text, _product_name.Text, _object_count.Text , _object_type.Text, _dept_area.Text,_dept_name.Text, _dept_address.Text, _mdd.Text, _bz.Text,username,loginid, System.DateTime.Now.Year.ToString(),System.DateTime.Now.Month.ToString(),System.DateTime.Now.Day.ToString() }; UcCertificateProductDetails cer = new UcCertificateProductDetails(cer_details); //grid_info.Children.Add(cer); PrintDialog dialog = new PrintDialog(); //if (dialog.ShowDialog() == true) //{ dialog.PrintQueue = GetPrinter(); Size printSize = new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight); cer.Measure(printSize); cer.Arrange(new Rect(0, 0, dialog.PrintableAreaWidth, dialog.PrintableAreaHeight)); //Size printSize = new Size(793, 529); //cer.Measure(printSize); //cer.Arrange(new Rect(0, 0, 793, 529)); dialog.PrintVisual(cer, "产品检疫证"); //} //Toolkit.MessageBox.Show("电子出证单生成成功!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); clear(); return; } else { Toolkit.MessageBox.Show("电子出证单生成失败!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } }