Ejemplo n.º 1
0
        /// <summary>
        /// 新增甘肃报表
        /// </summary>
        /// <param name="model"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public DataTable Insert(clsReportGS model, out string errMsg)
        {
            DataTable dt = null;

            errMsg = string.Empty;
            try
            {
                sql.Length = 0;
                sql.Append("Insert Into tReportGS (Title,FoodName,FoodType,ProductionDate,CheckedCompanyName,");
                sql.Append("CheckedCompanyAddress,CheckedCompanyPhone,LabelProducerName,LabelProducerAddress,LabelProducerPhone,");
                sql.Append("SamplingData,SamplingPerson,SampleNum,SamplingBase,SamplingAddress,");
                sql.Append("SamplingOrderCode,Standard,InspectionConclusion,Notes,Audit,Surveyor) ");
                sql.Append("VALUES(");
                sql.AppendFormat("'{0}',", model.Title);
                sql.AppendFormat("'{0}',", model.FoodName);
                sql.AppendFormat("'{0}',", model.FoodType);
                sql.AppendFormat("'{0}',", model.ProductionDate);
                sql.AppendFormat("'{0}',", model.CheckedCompanyName);

                sql.AppendFormat("'{0}',", model.CheckedCompanyAddress);
                sql.AppendFormat("'{0}',", model.CheckedCompanyPhone);
                sql.AppendFormat("'{0}',", model.LabelProducerName);
                sql.AppendFormat("'{0}',", model.LabelProducerAddress);
                sql.AppendFormat("'{0}',", model.LabelProducerPhone);

                sql.AppendFormat("'{0}',", model.SamplingData);
                sql.AppendFormat("'{0}',", model.SamplingPerson);
                sql.AppendFormat("'{0}',", model.SampleNum);
                sql.AppendFormat("'{0}',", model.SamplingBase);
                sql.AppendFormat("'{0}',", model.SamplingAddress);

                sql.AppendFormat("'{0}',", model.SamplingOrderCode);
                sql.AppendFormat("'{0}',", model.Standard);
                sql.AppendFormat("'{0}',", model.InspectionConclusion);
                sql.AppendFormat("'{0}',", model.Notes);
                sql.AppendFormat("'{0}',", model.Audit);
                sql.AppendFormat("'{0}')", model.Surveyor);
                DataBase.ExecuteCommand(sql.ToString(), out errMsg);
                sql.Length = 0;

                sql.Append("Select Top 1 * From tReportGS Order By ID Desc");
                string[] cmd = new string[1] {
                    sql.ToString()
                };
                string[] names = new string[1] {
                    "Result"
                };
                dt         = DataBase.GetDataSet(cmd, names, out errMsg).Tables["Result"];
                sql.Length = 0;
            }
            catch (Exception e)
            {
                errMsg = e.Message;
            }
            return(dt);
        }
        /// <summary>
        /// 保存报表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            string      error  = string.Empty;
            clsReportGS report = new clsReportGS();

            try
            {
                report.ID                    = _id;
                report.Title                 = this.textBoxTitle.Text.Trim();
                report.FoodName              = this.textBoxFoodName.Text.Trim();
                report.FoodType              = this.textBoxFoodType.Text.Trim();
                report.ProductionDate        = this.textBoxProductionDate.Text.Trim();
                report.CheckedCompanyName    = this.textBoxCheckedCompanyName.Text.Trim();
                report.CheckedCompanyAddress = this.textBoxCheckedCompanyAddress.Text.Trim();
                report.CheckedCompanyPhone   = this.textBoxCheckedCompanyPhone.Text.Trim();
                report.CheckedCompanyName    = this.textBoxCheckedCompanyName.Text.Trim();
                report.CheckedCompanyPhone   = this.textBoxCheckedCompanyPhone.Text.Trim();
                report.LabelProducerName     = this.textBoxLabelProducerName.Text.Trim();
                report.LabelProducerAddress  = this.textBoxLabelProducerAddress.Text.Trim();
                report.LabelProducerPhone    = this.textBoxLabelProducerPhone.Text.Trim();
                report.SamplingData          = this.textBoxSamplingData.Text.Trim();
                report.SamplingPerson        = this.textBoxSamplingPerson.Text.Trim();
                report.SampleNum             = this.textBoxSampleNum.Text.Trim();
                report.SamplingOrderCode     = this.textBoxSamplingOrderCode.Text.Trim();
                report.Standard              = this.textBoxStandard.Text.Trim();
                report.InspectionConclusion  = this.textBoxTInspectionConclusion.Text.Trim();
                new tlsttResultSecondOpr().Update(report, out error);
            }
            catch (Exception ex)
            {
                MessageBox.Show("出现异常!\n" + ex.Message.ToString());
            }
            finally
            {
                if (error.Equals(string.Empty))
                {
                    if (MessageBox.Show("保存成功!是否返回【报表界面】?", "操作提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("保存失败!\n" + error);
                }
            }
        }
        /// <summary>
        /// 删除报表 甘肃
        /// </summary>
        private void DeletdGS()
        {
            string error = string.Empty;

            try
            {
                if (dataGridGS.SelectedItems.Count <= 0)
                {
                    MessageBox.Show("请选择删除条目!");
                    return;
                }
                if (MessageBox.Show("确定要删除吗!?", "操作提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    try
                    {
                        clsReportGS report = (clsReportGS)dataGridGS.SelectedItems[0];
                        if (report != null && report.ID > 0)
                        {
                            _resultTable.DeletedGS(report.ID, out error);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        if (!error.Equals(string.Empty))
                        {
                            MessageBox.Show("删除时出现异常!\n" + error);
                        }
                        else
                        {
                            MessageBox.Show("删除报表数据成功!");
                        }
                        SearchReportGS();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常(Deletd):\n" + ex.Message);
            }
        }
 public void GetValues(clsReportGS report)
 {
     if (report != null)
     {
         try
         {
             _id = report.ID;
             if (report.Title != null && !report.Title.Equals(string.Empty))
             {
                 this.textBoxTitle.Text = report.Title;
             }
             this.textBoxFoodName.Text              = report.FoodName;;
             this.textBoxFoodType.Text              = report.FoodType;
             this.textBoxCheckedCompanyName.Text    = report.CheckedCompanyName;
             this.textBoxCheckedCompanyAddress.Text = report.CheckedCompanyAddress;
             this.textBoxCheckedCompanyPhone.Text   = report.CheckedCompanyPhone;
             this.textBoxLabelProducerName.Text     = report.LabelProducerName;
             this.textBoxLabelProducerAddress.Text  = report.LabelProducerAddress;
             this.textBoxLabelProducerPhone.Text    = report.LabelProducerPhone;
             this.textBoxSamplingData.Text          = report.SamplingData;
             this.textBoxSamplingPerson.Text        = report.SamplingPerson;
             this.textBoxSampleNum.Text             = report.SampleNum;
             //this.textBoxSamplingBase.Text = report.SamplingOrderCode;
             this.textBoxStandard.Text = report.Standard;
             this.textBoxTInspectionConclusion.Text = report.InspectionConclusion;
             if (report.reportList != null && report.reportList.Count > 0)
             {
                 DataGridRecord.DataContext = report.reportList;
             }
             else
             {
                 DataGridRecord.DataContext = null;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("异常(GetValues):\n" + ex.Message);
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 修改报表记录 GS
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Update(clsReportGS model, out string errMsg)
        {
            int rtn = 0;

            errMsg = string.Empty;
            try
            {
                sql.Length = 0;
                sql.Append("Update tReportGS Set ");
                sql.AppendFormat("Title='{0}',", model.Title == null ? string.Empty : model.Title);
                sql.AppendFormat("FoodName='{0}',", model.FoodName == null ? string.Empty : model.FoodName);
                sql.AppendFormat("FoodType='{0}',", model.FoodType == null ? string.Empty : model.FoodType);
                sql.AppendFormat("ProductionDate='{0}',", model.ProductionDate == null ? string.Empty : model.ProductionDate);
                sql.AppendFormat("CheckedCompanyName='{0}',", model.CheckedCompanyName == null ? string.Empty : model.CheckedCompanyName);
                sql.AppendFormat("CheckedCompanyAddress='{0}',", model.CheckedCompanyAddress == null ? string.Empty : model.CheckedCompanyAddress);
                sql.AppendFormat("CheckedCompanyPhone='{0}',", model.CheckedCompanyPhone == null ? string.Empty : model.CheckedCompanyPhone);
                sql.AppendFormat("LabelProducerName='{0}',", model.LabelProducerName == null ? string.Empty : model.LabelProducerName);
                sql.AppendFormat("LabelProducerAddress='{0}',", model.LabelProducerAddress == null ? string.Empty : model.LabelProducerAddress);
                sql.AppendFormat("LabelProducerPhone='{0}',", model.LabelProducerPhone == null ? string.Empty : model.LabelProducerPhone);
                sql.AppendFormat("SamplingData='{0}',", model.SamplingData == null ? string.Empty : model.SamplingData);
                sql.AppendFormat("SamplingPerson='{0}',", model.SamplingPerson == null ? string.Empty : model.SamplingPerson);
                sql.AppendFormat("SampleNum='{0}',", model.SampleNum == null ? string.Empty : model.SampleNum);
                sql.AppendFormat("SamplingBase='{0}',", model.SamplingBase == null ? string.Empty : model.SamplingBase);
                sql.AppendFormat("SamplingAddress='{0}',", model.SamplingAddress == null ? string.Empty : model.SamplingAddress);
                sql.AppendFormat("SamplingOrderCode='{0}',", model.SamplingOrderCode == null ? string.Empty : model.SamplingOrderCode);
                sql.AppendFormat("Standard='{0}',", model.Standard == null ? string.Empty : model.Standard);
                sql.AppendFormat("InspectionConclusion='{0}' ", model.InspectionConclusion == null ? string.Empty : model.InspectionConclusion);
                sql.AppendFormat("Where ID={0}", model.ID);
                DataBase.ExecuteCommand(sql.ToString(), out errMsg);
                sql.Length = 0;
                rtn        = 1;
            }
            catch (Exception e)
            {
                errMsg = e.Message;
            }
            return(rtn);
        }
        /// <summary>
        /// 打印甘肃报表
        /// </summary>
        private void PrintGS()
        {
            Global.GSType = string.Empty;
            clsReportGS record;

            try
            {
                if (dataGridGS.SelectedItems.Count > 0)
                {
                    record = (clsReportGS)dataGridGS.SelectedItems[0];
                    clsReportGS report = null;
                    if (record != null)
                    {
                        report                       = new clsReportGS();
                        report.Title                 = record.Title;
                        report.FoodName              = record.FoodName;
                        report.FoodType              = record.FoodType;
                        report.ProductionDate        = record.ProductionDate;
                        report.CheckedCompanyName    = record.CheckedCompanyName;
                        report.CheckedCompanyAddress = record.CheckedCompanyAddress;
                        report.CheckedCompanyPhone   = record.CheckedCompanyPhone;
                        report.LabelProducerName     = record.LabelProducerName;
                        report.LabelProducerAddress  = record.LabelProducerAddress;
                        report.LabelProducerPhone    = record.LabelProducerPhone;
                        report.SamplingData          = record.SamplingData;
                        report.SamplingPerson        = record.SamplingPerson;
                        report.SampleNum             = record.SampleNum;
                        report.SamplingBase          = record.SamplingBase;
                        report.SamplingAddress       = record.SamplingAddress;
                        report.SamplingOrderCode     = record.SamplingOrderCode;
                        report.Standard              = record.Standard;
                        report.InspectionConclusion  = record.InspectionConclusion;
                        report.Notes                 = record.Notes;
                        report.Surveyor              = record.Surveyor;

                        //根据主表ID查询子表样品信息集合
                        DataTable dt = _resultTable.GetReportDetailGS(record.ID);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            List <clsReportGSDetail> ItemNames = (List <clsReportGSDetail>)IListDataSet.DataTableToIList <clsReportGSDetail>(dt, 1);
                            for (int i = 0; i < ItemNames.Count; i++)
                            {
                                clsReportGS.ReportDetail reportDetail = new clsReportGS.ReportDetail();
                                reportDetail.ProjectName        = ItemNames[i].ProjectName;
                                reportDetail.Unit               = ItemNames[i].Unit;
                                reportDetail.InspectionStandard = ItemNames[i].InspectionStandard;
                                reportDetail.IndividualResults  = ItemNames[i].IndividualResults;
                                reportDetail.IndividualDecision = ItemNames[i].IndividualDecision;
                                report.reportDetailList.Add(reportDetail);
                            }
                        }
                    }
                    //甘肃打印模板
                    PrintPreviewWindow print = new PrintPreviewWindow("xaml\\Print\\PrintModel\\GSDocument.xaml", report, new OrderDocumentRenderer());
                    print._resultGS     = record;
                    print.Owner         = this;
                    print.ShowInTaskbar = false;
                    print.ShowDialog();
                }
                else
                {
                    MessageBox.Show("请选择打印条目!", "操作提示");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常(Print):\n" + ex.Message);
            }
        }
        /// <summary>
        /// 打印甘肃回执
        /// </summary>
        private void PrintGSHZ()
        {
            Global.GSType = "HZ";
            clsReportGS record;

            try
            {
                if (dataGridGS.SelectedItems.Count > 0)
                {
                    IDictionary <string, string> dicItems  = new Dictionary <string, string>();
                    IDictionary <string, string> dicSample = new Dictionary <string, string>();
                    record = (clsReportGS)dataGridGS.SelectedItems[0];
                    clsReportGS report = null;
                    if (record != null)
                    {
                        report                       = new clsReportGS();
                        report.Title                 = record.Title;
                        report.FoodName              = record.FoodName;
                        report.FoodType              = record.FoodType;
                        report.ProductionDate        = record.ProductionDate;
                        report.CheckedCompanyName    = record.CheckedCompanyName == null ? "______" : record.CheckedCompanyName;
                        report.CheckedCompanyAddress = record.CheckedCompanyAddress == null ? "______" : record.CheckedCompanyAddress;
                        report.CheckedCompanyPhone   = record.CheckedCompanyPhone;
                        report.LabelProducerName     = record.LabelProducerName;
                        report.LabelProducerAddress  = record.LabelProducerAddress == null ? "______" : record.LabelProducerAddress;
                        report.LabelProducerPhone    = record.LabelProducerPhone;
                        if (record.SamplingData != null)
                        {
                            report.SamplingData = record.SamplingData == null ? "____年__月__日" : record.SamplingData;
                            string   str = record.SamplingData;
                            string[] s   = str.Split(new char[] { '-' });
                            report.SamplingData = s[0] + "年" + s[1] + "月" + s[2] + "日";
                        }
                        else
                        {
                            report.SamplingData = "____年__月__日";
                        }
                        report.SamplingPerson       = record.SamplingPerson;
                        report.SampleNum            = record.SampleNum;
                        report.SamplingBase         = record.SamplingBase;
                        report.SamplingAddress      = record.SamplingAddress;
                        report.SamplingOrderCode    = record.SamplingOrderCode;
                        report.Standard             = record.Standard;
                        report.InspectionConclusion = record.InspectionConclusion;
                        report.Notes     = record.Notes;
                        report.Surveyor  = record.Surveyor;
                        report.ItemsList = report.UnqualifiedItemsList = report.SampleList = string.Empty;
                        //根据主表ID查询子表样品信息集合
                        DataTable dt = _resultTable.GetReportDetailGS(record.ID);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            List <clsReportGSDetail> ItemNames = (List <clsReportGSDetail>)IListDataSet.DataTableToIList <clsReportGSDetail>(dt, 1);
                            for (int i = 0; i < ItemNames.Count; i++)
                            {
                                clsReportGS.ReportDetail reportDetail = new clsReportGS.ReportDetail();
                                reportDetail.ProjectName        = ItemNames[i].ProjectName;
                                reportDetail.Unit               = ItemNames[i].Unit;
                                reportDetail.InspectionStandard = ItemNames[i].InspectionStandard;
                                reportDetail.IndividualResults  = ItemNames[i].IndividualResults;
                                reportDetail.IndividualDecision = ItemNames[i].IndividualDecision;
                                report.reportDetailList.Add(reportDetail);
                                if (!dicItems.ContainsKey(ItemNames[i].ProjectName))
                                {
                                    if (i + 1 < ItemNames.Count)
                                    {
                                        report.ItemsList += ItemNames[i].ProjectName + ",";
                                    }
                                    else
                                    {
                                        report.ItemsList += ItemNames[i].ProjectName;
                                    }
                                    dicItems.Add(ItemNames[i].ProjectName, ItemNames[i].ProjectName);
                                }
                                if (!dicSample.ContainsKey(ItemNames[i].ProjectName))
                                {
                                    if (ItemNames[i].IndividualDecision.Equals("不合格"))
                                    {
                                        if (i + 1 < ItemNames.Count)
                                        {
                                            report.UnqualifiedItemsList += ItemNames[i].ProjectName + ",";
                                        }
                                        else
                                        {
                                            report.UnqualifiedItemsList += ItemNames[i].ProjectName;
                                        }
                                        dicSample.Add(ItemNames[i].ProjectName, ItemNames[i].ProjectName);
                                    }
                                }
                            }
                            if (report.UnqualifiedItemsList.Equals(string.Empty))
                            {
                                report.UnqualifiedItemsList = "____________________";
                            }
                            if (report.ItemsList.Equals(string.Empty))
                            {
                                report.ItemsList = "____________________";
                            }
                        }
                    }
                    //甘肃打印回执
                    PrintPreviewWindow print = new PrintPreviewWindow("xaml\\Print\\PrintModel\\GSHZDocument.xaml", report, new OrderDocumentRenderer());
                    print._resultGS     = record;
                    print.Owner         = this;
                    print.ShowInTaskbar = false;
                    print.ShowDialog();
                }
                else
                {
                    MessageBox.Show("请选择打印条目!", "操作提示");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常(Print):\n" + ex.Message);
            }
        }