Exemplo n.º 1
0
        public static List <t_goods> GetGoodsListFromSql(string str)
        {
            List <t_goods> result = new List <t_goods>();
            string         sql    = @"
                            select * from t_goods where `status`=1 {0} limit 0,10;
                        ";

            using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon))
            {
                string strWhere = "";
                if (!string.IsNullOrEmpty(str))
                {
                    strWhere += " and (goodsName like '%" + str + "%' or type like '%" + str + "%')";
                }

                sql = string.Format(sql, strWhere);
                sql_conn.Open();
                MySqlCommand cmd = new MySqlCommand(sql, sql_conn);
                DataSet      ds  = new DataSet();

                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                adapter.Fill(ds);
                result = (List <t_goods>)IListDataSet.DataSetToIList <t_goods>(ds, 0);
                return(result);
            }
        }
Exemplo n.º 2
0
        public static List <t_unit_goods> GetGoodsByUnitID(int UnitID, ref string code)
        {
            List <t_unit_goods> result = new List <t_unit_goods>();
            string sql = @"
                            select * from t_unit where status_code!=-1 {0};
                            select * from t_unit_goods  where status_code!=-1 {1} ;
                        ";

            //select count(1) as goods_id,sum(x1.count + 0) AS count, convert(sum(x1.price * x1.count), UNSIGNED) as price,convert(sum(x1.sell_min_price * x1.count), UNSIGNED) as sell_min_price, convert(sum(x1.sell_max_price * x1.count), UNSIGNED) as sell_max_price   from t_unit_goods x1 where x1.status_code != -1 { 0}

            using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon))
            {
                string strWhere  = "";
                string strWhere2 = "";
                if (!string.IsNullOrEmpty(UnitID.ToString()) && UnitID != 0)
                {
                    strWhere  += " and unit_id=" + UnitID + "";
                    strWhere2 += " and id=" + UnitID + "";
                }

                sql = string.Format(sql, strWhere2, strWhere);
                sql_conn.Open();
                MySqlCommand cmd = new MySqlCommand(sql, sql_conn);
                DataSet      ds  = new DataSet();

                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                adapter.Fill(ds);
                code   = ((List <t_unit>)IListDataSet.DataSetToIList <t_unit>(ds, 0)).FirstOrDefault().code;
                result = (List <t_unit_goods>)IListDataSet.DataSetToIList <t_unit_goods>(ds, 1);
                return(result);
            }
        }
Exemplo n.º 3
0
        public static List <t_unit_goods> GetUnitGoodsListById(int id)
        {
            List <t_unit_goods> result = new List <t_unit_goods>();
            string sql = @"
                            select x1.* from t_unit_goods x1 
left join  t_goods x2 on x1.goods_id=x2.id
where x1.status_code!=-1 {0} ;
                        ";

            //select count(1) as goods_id,sum(x1.count + 0) AS count, convert(sum(x1.price * x1.count), UNSIGNED) as price,convert(sum(x1.sell_min_price * x1.count), UNSIGNED) as sell_min_price, convert(sum(x1.sell_max_price * x1.count), UNSIGNED) as sell_max_price   from t_unit_goods x1 where x1.status_code != -1 { 0}

            using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon))
            {
                string strWhere = "";
                if (!string.IsNullOrEmpty(id.ToString()) && id != 0)
                {
                    strWhere += " and x1.unit_id=" + id + "";
                }

                sql = string.Format(sql, strWhere);
                sql_conn.Open();
                MySqlCommand cmd = new MySqlCommand(sql, sql_conn);
                DataSet      ds  = new DataSet();

                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                adapter.Fill(ds);

                result = (List <t_unit_goods>)IListDataSet.DataSetToIList <t_unit_goods>(ds, 0);
            }
            return(result);
        }
Exemplo n.º 4
0
        public static t_unit GetModel(long id)
        {
            t_unit result = new t_unit();
            string sql    = @"
                            select  * from t_unit where status_code!=-1 {0} ;
                        ";

            using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon))
            {
                string strWhere = "";
                if (!string.IsNullOrEmpty(id.ToString()) && id != 0)
                {
                    strWhere += " and id= " + id + "";
                }

                sql = string.Format(sql, strWhere);
                sql_conn.Open();
                MySqlCommand cmd = new MySqlCommand(sql, sql_conn);
                DataSet      ds  = new DataSet();

                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                adapter.Fill(ds);

                result = (t_unit)IListDataSet.DataSetToIList <t_unit>(ds, 0)[0];
                return(result);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 海量数据插入方法
        /// </summary>
        /// <typeparam name="db"></typeparam>
        /// <typeparam name="entityType">实体类型名称</typeparam>
        /// <param name="list"></param>
        public virtual void AddByBulkCopy(DbContext db, Type entityType, IList list)
        {
            DataSet ds = IListDataSet.ToDataSet(list);

            if (ds.Tables.Count > 0)
            {
                AddByBulkCopy((SqlConnection)db.Database.Connection, ds.Tables[0], entityType.Name);
            }
        }
Exemplo n.º 6
0
        public static List <t_unit_goods_list> GetUnitGoodsListData(string unit_id, string goods_type, string goods_name, string MD5, decimal?min_price, decimal?max_price, int pageIndex, int pageSize, ref int total)
        {
            List <t_unit_goods_list> result = new List <t_unit_goods_list>();
            string sql = @"
                         select SQL_CALC_FOUND_ROWS x2.`code`,x2.unit_name,x3.goodsName ,x1.* from t_unit_goods_list x1 
left join t_unit x2 on x1.unit_id=x2.id 
left join t_goods x3 on x1.goods_id=x3.id
where x1.status_code!=-1 {0}
  order by x1.random_num asc
                            limit @begin,@pagesize;
                            SELECT FOUND_ROWS() as total;;
                        ";

            using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon))
            {
                string strWhere = "";
                if (!string.IsNullOrEmpty(unit_id) && unit_id != "0")
                {
                    strWhere += " and x1.unit_id=" + unit_id + "";
                }

                if (!string.IsNullOrEmpty(goods_type))
                {
                    strWhere += " and (x3.type like '%" + goods_type + "%' or x3.topType like '%" + goods_type + "%')";
                }
                if (!string.IsNullOrEmpty(MD5))
                {
                    strWhere += " and (x1.MD5_1 = '" + MD5 + "' or x1.MD5_2='" + MD5 + "' or x1.MD5_3='" + MD5 + "' or x1.MD5_4='" + MD5 + "' or x1.MD5_5='" + MD5 + "')";
                }
                if (!string.IsNullOrEmpty(goods_name))
                {
                    strWhere += " and (x3.goods_name like '%" + goods_name + "%' or x1.goods_name_new like '%" + goods_name + "%')";
                }


                if (min_price != null && min_price != 0)
                {
                }

                if (max_price != null && max_price != 0)
                {
                }
                sql = string.Format(sql, strWhere);
                sql_conn.Open();
                MySqlCommand cmd = new MySqlCommand(sql, sql_conn);
                DataSet      ds  = new DataSet();
                cmd.Parameters.AddWithValue("@begin", (pageIndex - 1) * pageSize);
                cmd.Parameters.AddWithValue("@pagesize", pageSize);
                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                adapter.Fill(ds);

                result = (List <t_unit_goods_list>)IListDataSet.DataSetToIList <t_unit_goods_list>(ds, 0);
                total  = int.Parse(ds.Tables[1].Rows[0][0].ToString());
                return(result);
            }
        }
 /// <summary>
 /// 初始化数据
 /// </summary>
 public void InitializeData(DataTable dataTable)
 {
     if (dataTable != null && dataTable.Rows.Count > 0)
     {
         _dataTable = dataTable;
         List <tlsTtResultSecond> ItemList = new List <tlsTtResultSecond>();
         try
         {
             ItemList = (List <tlsTtResultSecond>)IListDataSet.DataTableToIList <tlsTtResultSecond>(_dataTable, 1);
             if (ItemList.Count > 0)
             {
                 for (int i = 0; i < ItemList.Count; i++)
                 {
                     if (ItemList[i].Result != null)
                     {
                         if (ItemList[i].Result.Trim().Equals("合格"))
                         {
                             _qualifiedCount += 1;
                         }
                         else if (ItemList[i].Result.Trim().Equals("不合格"))
                         {
                             _unqualifiedCount += 1;
                         }
                         else
                         {
                             _otherCount += 1;
                         }
                     }
                     else
                     {
                         _otherCount += 1;
                     }
                 }
             }
             _totalCount = dataTable.Rows.Count;
             double percent = Convert.ToDouble(_qualifiedCount) / Convert.ToDouble(_totalCount);
             string result  = string.Format("{0:0.00%}", percent);
             this.labeltotalCount.Content       = "本次数据统计共 " + _totalCount + " 条数据";
             this.labelqualifiedCount.Content   = "合格数: " + _qualifiedCount;
             this.labelunqualifiedCount.Content = "不合格数: " + _unqualifiedCount;
             this.labelotherCount.Content       = "其他: " + _otherCount;
             this.labelCount.Content            = "合格率: " + result;
             DataGridRecord.DataContext         = ItemList;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else
     {
         DataGridRecord.DataContext = null;
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// 查看数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_selectData_Click(object sender, RoutedEventArgs e)
        {
            _isRead  = false;
            _atpLsit = new List <clsATP>();
            DataTable data = _atpBll.GetAllAsDataTable();

            if (data != null)
            {
                _atpLsit = (List <clsATP>)IListDataSet.DataTableToIList <clsATP>(data, 1);
                this.DataGridRecord.DataContext = _atpLsit;
            }
        }
Exemplo n.º 9
0
        public static List <t_unit> GetList(int currentPage, int pagesize, string code, string unit_kind, string unit_name, string price, string status_code, ref int total)
        {
            List <t_unit> result = new List <t_unit>();
            string        sql    = @"
                           select SQL_CALC_FOUND_ROWS  * from t_unit x1 
left join (select unit_id, convert(count(1), UNSIGNED)  as goods_count,  convert(sum(count), UNSIGNED)  as goods_num from t_unit_goods  where status_code=1  group by unit_id)x2
on x1.id=x2.unit_id where x1.status_code!=-1 {0} order by x1.id limit @begin,@pagesize;

                            SELECT FOUND_ROWS() as total; 
                        ";

            using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon))
            {
                string strWhere = "";
                if (!string.IsNullOrEmpty(code))
                {
                    strWhere += " and code like '%" + code + "%'";
                }
                if (!string.IsNullOrEmpty(unit_kind))
                {
                    strWhere += " and unit_kind like'%" + unit_kind + "%'";
                }
                if (!string.IsNullOrEmpty(unit_name))
                {
                    strWhere += " and unit_name like'%" + unit_name + "%'";
                }


                if (!string.IsNullOrEmpty(price) && price != "0")
                {
                    strWhere += " and price=" + price + "";
                }
                //if (!string.IsNullOrEmpty(status_code))
                //{
                //    strWhere += " and status_code='" + status_code + "'";
                //}


                sql = string.Format(sql, strWhere);
                sql_conn.Open();
                MySqlCommand cmd = new MySqlCommand(sql, sql_conn);
                DataSet      ds  = new DataSet();
                cmd.Parameters.AddWithValue("@begin", (currentPage - 1) * pagesize);
                cmd.Parameters.AddWithValue("@pagesize", pagesize);
                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                adapter.Fill(ds);
                total  = int.Parse(ds.Tables[1].Rows[0][0].ToString());
                result = (List <t_unit>)IListDataSet.DataSetToIList <t_unit>(ds, 0);
                return(result);
            }
        }
        /// <summary>
        /// 查询被检单位
        /// </summary>
        private void SearchCompany()
        {
            this.DataGridRecord.DataContext = null;
            DataTable dataTable = _clsCompanyOprbll.GetAsDataTable("FULLNAME Like '%" + textBoxCompanyName.Text.Trim().ToString() + "%'");

            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                List <clsCompany> ItemNames = (List <clsCompany>)IListDataSet.DataTableToIList <clsCompany>(dataTable, 1);
                if (ItemNames.Count > 0)
                {
                    this.DataGridRecord.DataContext = ItemNames;
                }
            }
        }
Exemplo n.º 11
0
 public void BindData(object list)
 {
     usersInfoBindingSource.DataSource = BLLFty.Create <BaseBLL>().GetListByNoTracking <UsersInfo>(o => o.IsDel == false && !string.IsNullOrEmpty(o.Password));
     dsPermission = IListDataSet.ToDataSet <Permission>(BLLFty.Create <BaseBLL>().GetListBy <Permission>(o => o.UserID == MainForm.usersInfo.ID));
     if (dsPermission.Tables[0].Rows.Count > 0)
     {
         cuTreeListPermission.DataSource                 = dsPermission.Tables[0];
         cuTreeListPermission.CheckedStateFieldName      = "CheckBoxState";
         cuTreeListPermission.Columns["Caption"].Caption = "功能名称";
         cuTreeListPermission.Columns["Caption"].OptionsColumn.AllowEdit = false;
         cuTreeListPermission.Columns["SerialNo"].Visible      = false;
         cuTreeListPermission.Columns["UserID"].Visible        = false;
         cuTreeListPermission.Columns["CheckBoxState"].Visible = false;
     }
 }
        /// <summary>
        /// 查询样品
        /// </summary>
        private void SearchSampleByName()
        {
            DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(textBoxName.Text.Trim(), _projectName, false, _IsFirst, 1);

            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                _Items = (List <clsttStandardDecide>)IListDataSet.DataTableToIList <clsttStandardDecide>(dataTable, 1);
                this.DataGridRecord.ItemsSource = dataTable.DefaultView;
                _IsFirst = false;
            }
            else
            {
                this.DataGridRecord.ItemsSource = null;
            }
        }
Exemplo n.º 13
0
        private void SearchTask()
        {
            this.DataGridRecord.ItemsSource = null;
            DataTable dt = _Tskbll.GetAsDataTable(string.Empty, string.Empty, 1);

            if (dt != null && dt.Rows.Count > 0)
            {
                List <tlsTrTask> Items = (List <tlsTrTask>)IListDataSet.DataTableToIList <tlsTrTask>(dt, 1);
                this.DataGridRecord.ItemsSource = (Items != null && Items.Count > 0) ? Items : null;
            }
            else
            {
                this.DataGridRecord.ItemsSource = null;
            }
        }
Exemplo n.º 14
0
        private DataTable ListToDataTable()
        {
            string[]          PropertyName = new string[43];
            int               PropertyNum  = 0;
            tlsTtResultSecond Rs           = new tlsTtResultSecond();
            Type              t            = Rs.GetType();

            foreach (PropertyInfo pi in t.GetProperties())
            {
                PropertyName[PropertyNum] = pi.Name;
                PropertyNum++;
            }
            DataSet dto = IListDataSet.ToDataSet <tlsTtResultSecond>(_selectedRecords, PropertyName);

            return(dto.Tables[0]);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 获取相机序列化数据
        /// </summary>
        /// <returns>反馈序列化数据</returns>
        private List <VM_Content> GetCameraInfo(CameraStatus flag, ref string test)
        {
            IList <VM_CameraParameters> camerList = new List <VM_CameraParameters>();
            CamereBLL camereBLL = new CamereBLL();
            DataSet   ds        = new DataSet();

            ds        = camereBLL.GetCameraList("");
            camerList = IListDataSet.DataSetToIList <VM_CameraParameters>(ds, 0);
            //if (m_VoltageLevel == 0)
            //{
            //    camerList = camerList.Where(s => s.exposureMode == "0").ToList();
            //}
            //else
            //{
            //    camerList = camerList.Where(s => s.exposureMode == m_VoltageLevel.ToString()).ToList();
            //}
            camerList = camerList.Where(s => s.exposureMode == m_VoltageLevel.ToString()).ToList();
            IList <VM_Content> camerList2 = new List <VM_Content>();

            if (flag == CameraStatus.Start)
            {
                camerList2.Add(new VM_Content {
                    startTag = "Y", isMulti = "N", illumination = "1", station = "heifei", CameraParameters = camerList
                });
            }
            else if (flag == CameraStatus.Stop)
            {
                camerList2.Add(new VM_Content {
                    startTag = "N", isMulti = "N", illumination = "1", station = "heifei", CameraParameters = camerList
                });
            }
            else
            {
                camerList2.Add(new VM_Content {
                    startTag = "N", isMulti = "N", illumination = "1", station = "heifei", CameraParameters = camerList
                });
            }

            //序列化
            var lists = Newtonsoft.Json.JsonConvert.SerializeObject(camerList2);

            test = lists.ToString();
            //反序列化
            //Newtonsoft.Json.JsonConvert.DeserializeObject<List<VM_Content>>(lists);
            return(null);
        }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     if (_dataTable != null && _dataTable.Rows.Count > 0)
     {
         List <tlsTtResultSecond> ItemList = new List <tlsTtResultSecond>();
         try
         {
             ItemList = (List <tlsTtResultSecond>)IListDataSet.DataTableToIList <tlsTtResultSecond>(_dataTable, 1);
             if (ItemList.Count > 0)
             {
                 for (int i = 0; i < ItemList.Count; i++)
                 {
                     if (ItemList[i].Result != null)
                     {
                         if (ItemList[i].Result.Trim().Equals("合格"))
                         {
                             _qualifiedList.Add(ItemList[i]);
                             _qualified++;
                         }
                         else if (ItemList[i].Result.Trim().Equals("不合格"))
                         {
                             _unqualified++;
                             _unqualifiedList.Add(ItemList[i]);
                         }
                         else
                         {
                             _other++;
                             _otherList.Add(ItemList[i]);
                         }
                     }
                     else
                     {
                         _other++;
                         _otherList.Add(ItemList[i]);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     Assembly();
 }
        /// <summary>
        /// 查询样品
        /// </summary>
        private void SearchSample()
        {
            this.DataGridRecord.DataContext = null;
            DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(textBoxSampleName.Text.Trim(), textBoxName.Text.Trim(), false, _IsFirst, 1);

            if (dataTable != null)
            {
                List <clsttStandardDecide> ItemNames = (List <clsttStandardDecide>)IListDataSet.DataTableToIList <clsttStandardDecide>(dataTable, 1);
                if (ItemNames != null && ItemNames.Count > 0)
                {
                    this.DataGridRecord.DataContext = ItemNames;
                    _IsFirst = false;
                    if (_ItemNames.Count <= 0)
                    {
                        _ItemNames = ItemNames;
                    }
                }
            }
        }
Exemplo n.º 18
0
        public static List <t_goods> GetGoodsList(int currentPage, int pagesize, string type, string goodsName, string minPrice, string maxPrice, ref int total)
        {
            List <t_goods> result = new List <t_goods>();
            string         sql    = @"
                            select SQL_CALC_FOUND_ROWS  * from t_goods where `status`=1 {0}  order by id desc limit @begin,@pagesize;
                            SELECT FOUND_ROWS() as total; 
                        ";

            using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon))
            {
                string strWhere = "";
                if (!string.IsNullOrEmpty(type))
                {
                    strWhere += " and (type like '%" + type + "%' or topType like '%" + type + "%')";
                }
                if (!string.IsNullOrEmpty(goodsName))
                {
                    strWhere += " and goodsName like'%" + goodsName + "%'";
                }

                if (!string.IsNullOrEmpty(minPrice))
                {
                    strWhere += " and minPrice>=" + minPrice + "";
                }
                if (!string.IsNullOrEmpty(maxPrice))
                {
                    strWhere += " and minPrice<=" + maxPrice + "";
                }

                sql = string.Format(sql, strWhere);
                sql_conn.Open();
                MySqlCommand cmd = new MySqlCommand(sql, sql_conn);
                DataSet      ds  = new DataSet();
                cmd.Parameters.AddWithValue("@begin", (currentPage - 1) * pagesize);
                cmd.Parameters.AddWithValue("@pagesize", pagesize);
                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                adapter.Fill(ds);
                total  = int.Parse(ds.Tables[1].Rows[0][0].ToString());
                result = (List <t_goods>)IListDataSet.DataSetToIList <t_goods>(ds, 0);
                return(result);
            }
        }
Exemplo n.º 19
0
        void GetPermission(object sender)
        {
            UsersInfo user = ((DevExpress.XtraGrid.Views.Layout.LayoutView)sender).GetFocusedRow() as UsersInfo;

            if (user != null)
            {
                dsPermission = IListDataSet.ToDataSet <Permission>(BLLFty.Create <BaseBLL>().GetListBy <Permission>(o => o.UserID == user.ID));
                cuTreeListPermission.DataSource = dsPermission.Tables[0];
                cuTreeListPermission.ExpandAll();
                foreach (TreeListNode node in cuTreeListPermission.GetNodeList())
                {
                    DataRowView drv = cuTreeListPermission.GetDataRecordByNode(node) as DataRowView;
                    if (drv != null)
                    {
                        node.Checked = (bool)drv["CheckBoxState"];
                    }
                }
                buttonPermissionBindingSource.DataSource = btnPermissionList = BLLFty.Create <BaseBLL>().GetListBy <ButtonPermission>(o => o.UserID == user.ID);
            }
        }
        /// <summary>
        /// 编辑原始报表
        /// </summary>
        private void Edit()
        {
            clsReport report;

            try
            {
                if (DataGridRecord.SelectedItems.Count > 0)
                {
                    report = (clsReport)DataGridRecord.SelectedItems[0];
                    //根据主表ID查询子表样品信息集合
                    DataTable dt = _resultTable.GetReportDetail(report.ID);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        List <clsReportDetail> ItemNames = (List <clsReportDetail>)IListDataSet.DataTableToIList <clsReportDetail>(dt, 1);
                        for (int i = 0; i < ItemNames.Count; i++)
                        {
                            DYSeriesDataSet.DataModel.clsReport.ReportDetail reportDetail = new DYSeriesDataSet.DataModel.clsReport.ReportDetail();
                            reportDetail.FoodName    = ItemNames[i].FoodName;
                            reportDetail.ProjectName = ItemNames[i].ProjectName;
                            reportDetail.Unit        = ItemNames[i].Unit;
                            reportDetail.CheckData   = ItemNames[i].CheckData;
                            report.reportDetailList.Add(reportDetail);
                        }
                    }
                    UpdateReportWindow window = new UpdateReportWindow();
                    window.ShowInTaskbar = false;
                    window.Owner         = this;
                    window.GetValues(report);
                    window.ShowDialog();
                    SearchReport();
                }
                else
                {
                    MessageBox.Show("请选择编辑条目!", "操作提示");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常(Edit):\n" + ex.Message);
            }
        }
 /// <summary>
 /// 查询原始报表
 /// </summary>
 private void SearchReport()
 {
     this.DataGridRecord.DataContext = null;
     try
     {
         SqlWhere();
         string    error = string.Empty;
         DataTable dt    = _resultTable.GetReport(_SqlWhere, 1, out error);
         if (dt != null && dt.Rows.Count > 0)
         {
             List <clsReport> Items = (List <clsReport>)IListDataSet.DataTableToIList <clsReport>(dt, 1);
             this.DataGridRecord.DataContext = Items;
         }
         else if (!error.Equals(string.Empty))
         {
             MessageBox.Show(error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("异常(SearchReport):\n" + ex.Message);
     }
 }
Exemplo n.º 22
0
 public bool Save()
 {
     try
     {
         this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
         bool flag = false;
         if (dsPermission == null)
         {
             CommonServices.ErrorTrace.SetErrorInfo(this.FindForm(), "该用户没有操作权限");
             flag = true;
         }
         if (btnPermissionList == null)
         {
             CommonServices.ErrorTrace.SetErrorInfo(this.FindForm(), "该用户没有按钮控制权限");
             flag = true;
         }
         if (flag)
         {
             return(false);
         }
         BLLFty.Create <PermissionBLL>().Update(IListDataSet.DataSetToIList <Permission>(dsPermission, 0).ToList(), btnPermissionList);
         //vStockOutBillDtlForPrintBindingSource.DataSource = BLLFty.Create<StockOutBillBLL>().GetStockOutBillDtlForPrint(hd.ID);
         //gvBillDtlForPrint.BestFitColumns();
         clientFactory.DataPageRefresh <Permission>().OrderBy(o => o.SerialNo);
         CommonServices.ErrorTrace.SetSuccessfullyInfo(this.FindForm(), "保存成功");
         return(true);
     }
     catch (Exception ex)
     {
         CommonServices.ErrorTrace.SetErrorInfo(this.FindForm(), ex.Message);
         return(false);
     }
     finally
     {
         this.Cursor = System.Windows.Forms.Cursors.Default;
     }
 }
 private void btnCleanRepeatSample_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(string.Empty, string.Empty, false, false, 1);
         if (dataTable != null && dataTable.Rows.Count > 0)
         {
             List <clsttStandardDecide> ItemNames = (List <clsttStandardDecide>)IListDataSet.DataTableToIList <clsttStandardDecide>(dataTable, 1);
             if (ItemNames != null && ItemNames.Count > 0)
             {
                 int delNum = 0;
                 IDictionary <string, clsttStandardDecide> dicItems = new Dictionary <string, clsttStandardDecide>();
                 string err = String.Empty;
                 for (int i = 0; i < ItemNames.Count; i++)
                 {
                     //key=样品名称+项目名称+标准名称     //+标准值+判定符号+单位
                     string key = ItemNames[i].FtypeNmae + "_" + ItemNames[i].Name + "_" + ItemNames[i].ItemDes;
                     //+ "_" + ItemNames[i].StandardValue + "_" + ItemNames[i].Demarcate + "_" + ItemNames[i].Unit;
                     if (!dicItems.ContainsKey(key))
                     {
                         dicItems.Add(key, ItemNames[i]);
                     }
                     else
                     {
                         if (_clsttStandardDecideOpr.DeleteByID(ItemNames[i].ID, out err) == 1)
                         {
                             delNum += 1;
                         }
                     }
                 }
                 if (delNum > 0)
                 {
                     MessageBox.Show("成功清理 " + delNum + " 条重复国家检测标准!");
                 }
                 else
                 {
                     MessageBox.Show("暂无重复国家检测标准!");
                 }
                 SearchSample();
             }
         }
         else
         {
             MessageBox.Show("暂无国家检测标准需要清理!", "操作提示");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("异常:\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);
            }
        }
        /// <summary>
        /// 给控件赋值
        /// </summary>
        private void SetCheckBox()
        {
            //标准名称
            IList <string> ItemDesList = new List <string>();
            IDictionary <string, string> dicItemDes = new Dictionary <string, string>();
            //样品名称
            IList <string> SampleNameList = new List <string>();
            IDictionary <string, string> dicSampleName = new Dictionary <string, string>();
            //项目名称
            IList <string> ItemsList = new List <string>();
            IDictionary <string, string> dicItems = new Dictionary <string, string>();
            //判定符号
            IList <string> DemarcateList = new List <string>();
            IDictionary <string, string> dicDemarcate = new Dictionary <string, string>();
            //单位
            IList <string> UnitList = new List <string>();
            IDictionary <string, string> dicUnit = new Dictionary <string, string>();

            try
            {
                //样品、单位、判定符号需单独从数据库中获取
                DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(string.Empty, string.Empty, false, false, 1);
                if (dataTable != null && dataTable.Rows.Count > 0)
                {
                    List <clsttStandardDecide> ItemNames = (List <clsttStandardDecide>)IListDataSet.DataTableToIList <clsttStandardDecide>(dataTable, 1);
                    if (ItemNames != null && ItemNames.Count > 0)
                    {
                        for (int i = 0; i < ItemNames.Count; i++)
                        {
                            string str = ItemNames[i].FtypeNmae;
                            if (!dicSampleName.ContainsKey(str) && !str.Equals(string.Empty))
                            {
                                dicSampleName.Add(str, str);
                                SampleNameList.Add(str);
                            }
                            str = ItemNames[i].Unit;
                            if (!str.Equals(string.Empty) && !dicUnit.ContainsKey(str))
                            {
                                dicUnit.Add(str, str);
                                UnitList.Add(str);
                            }
                            str = ItemNames[i].Demarcate;
                            if (!str.Equals(string.Empty) && !dicDemarcate.ContainsKey(str))
                            {
                                dicDemarcate.Add(str, str);
                                DemarcateList.Add(str);
                            }
                        }
                    }
                }

                for (int i = 0; i < _ItemNames.Count; i++)
                {
                    string str = _ItemNames[i].ItemDes;
                    if (!dicItemDes.ContainsKey(str) && !str.Equals(string.Empty))
                    {
                        dicItemDes.Add(str, str);
                        ItemDesList.Add(str);
                    }
                    str = _ItemNames[i].Name;
                    if (!dicItems.ContainsKey(str) && !str.Equals(string.Empty))
                    {
                        dicItems.Add(str, str);
                        ItemsList.Add(str);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常:" + ex.Message);
            }
            finally
            {
                this.textBoxFtypeNmae.ItemsSource = SampleNameList;
                this.textBoxName.ItemsSource      = ItemsList;
                this.textBoxItemDes.ItemsSource   = ItemDesList;
                this.textBoxItemDes.Text          = _ItemNames[0].ItemDes;
                this.textBoxDemarcate.ItemsSource = DemarcateList;
                this.textBoxDemarcate.Text        = _ItemNames[0].Demarcate;
                this.textBoxUnit.ItemsSource      = UnitList;
                this.textBoxUnit.Text             = _ItemNames[0].Unit;
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_decide != null && _decide.ID > 0)
                {
                    textBoxFtypeNmae.Text     = _decide.FtypeNmae;
                    textBoxSampleNum.Text     = _decide.SampleNum;
                    textBoxName.Text          = _decide.Name;
                    textBoxItemDes.Text       = _decide.ItemDes;
                    textBoxStandardValue.Text = _decide.StandardValue;
                    textBoxDemarcate.Text     = _decide.Demarcate;
                    textBoxUnit.Text          = _decide.Unit;
                }
                else
                {
                    this.Title = "新增国家检测标准";
                }

                if (_sampleName.Length > 0)
                {
                    this.textBoxFtypeNmae.Text       = _sampleName;
                    this.textBoxFtypeNmae.IsReadOnly = false;
                }

                if (_projectName.Length > 0 && _ItemNames != null && _ItemNames.Count == 0)
                {
                    DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(string.Empty, _projectName, true, true, 1);
                    if (dataTable != null && dataTable.Rows.Count > 0)
                    {
                        _ItemNames = (List <clsttStandardDecide>)IListDataSet.DataTableToIList <clsttStandardDecide>(dataTable, 1);
                    }
                }

                if (_ItemNames != null && _ItemNames.Count > 0)
                {
                    SetCheckBox();
                }
                else
                {
                    DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(string.Empty, string.Empty, false, false, 1);
                    if (dataTable != null && dataTable.Rows.Count > 0)
                    {
                        _ItemNames = (List <clsttStandardDecide>)IListDataSet.DataTableToIList <clsttStandardDecide>(dataTable, 1);
                        SetCheckBox();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常:" + ex.Message);
            }
            finally
            {
                values.Add(textBoxFtypeNmae.Text.Trim());
                values.Add(textBoxSampleNum.Text.Trim());
                values.Add(textBoxName.Text.Trim());
                values.Add(textBoxItemDes.Text.Trim());
                values.Add(textBoxStandardValue.Text);
                values.Add(textBoxDemarcate.Text);
                values.Add(textBoxUnit.Text);
                _isUpdate = false;
            }
        }
        /// <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 Print()
        {
            clsReport record;

            try
            {
                if (DataGridRecord.SelectedItems.Count > 0)
                {
                    record = (clsReport)DataGridRecord.SelectedItems[0];
                    ReportClass report = null;
                    if (record != null)
                    {
                        report                        = new ReportClass();
                        report.r_Title                = record.Title;
                        report.r_CheckUnitName        = record.CheckUnitName;
                        report.r_Trademark            = record.Trademark;
                        report.r_Specifications       = record.Specifications;
                        report.r_ProductionDate       = record.ProductionDate;
                        report.r_QualityGrade         = record.QualityGrade;
                        report.r_CheckedCompanyName   = record.CheckedCompanyName;
                        report.r_CheckedCompanyPhone  = record.CheckedCompanyPhone;
                        report.r_ProductionUnitsName  = record.ProductionUnitsName;
                        report.r_ProductionUnitsPhone = record.ProductionUnitsPhone;
                        report.r_TaskSource           = record.TaskSource;
                        report.r_Standard             = record.Standard;
                        report.r_SamplingData         = record.SamplingData;
                        report.r_SampleNum            = record.SampleNum;
                        report.r_SamplingCode         = record.SamplingCode;
                        report.r_SampleArrivalData    = record.SampleArrivalData;
                        report.r_Note                 = record.Notes;

                        //根据主表ID查询子表样品信息集合
                        DataTable dt = _resultTable.GetReportDetail(record.ID);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            List <clsReportDetail> ItemNames = (List <clsReportDetail>)IListDataSet.DataTableToIList <clsReportDetail>(dt, 1);
                            for (int i = 0; i < ItemNames.Count; i++)
                            {
                                ReportClass.ReportDetail reportDetail = new ReportClass.ReportDetail();
                                reportDetail.FoodName    = ItemNames[i].FoodName;
                                reportDetail.ProjectName = ItemNames[i].ProjectName;
                                reportDetail.Unit        = ItemNames[i].Unit;
                                reportDetail.CheckData   = ItemNames[i].CheckData;
                                report.r_reportList.Add(reportDetail);
                            }
                        }
                    }
                    //原始打印模板
                    PrintPreviewWindow print = new PrintPreviewWindow("xaml\\Print\\PrintModel\\OrderDocument.xaml", report, new OrderDocumentRenderer());
                    print._result       = 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 EditGS()
        {
            clsReportGS report;

            try
            {
                if (dataGridGS.SelectedItems.Count > 0)
                {
                    report = (clsReportGS)dataGridGS.SelectedItems[0];
                    //根据主表ID查询子表样品信息集合
                    DataTable dt = _resultTable.GetReportDetailGS(report.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++)
                        {
                            DYSeriesDataSet.DataModel.clsReportGS.ReportDetail reportDetail = new DYSeriesDataSet.DataModel.clsReportGS.ReportDetail();
                            reportDetail.ID                 = ItemNames[i].ID;
                            reportDetail.ReportGSID         = ItemNames[i].ReportGSID;
                            reportDetail.ProjectName        = ItemNames[i].ProjectName;
                            reportDetail.InspectionStandard = ItemNames[i].InspectionStandard;
                            reportDetail.IndividualResults  = ItemNames[i].IndividualResults;
                            reportDetail.Unit               = ItemNames[i].Unit;
                            reportDetail.IndividualDecision = ItemNames[i].IndividualDecision;
                            report.reportDetailList.Add(reportDetail);
                        }
                    }
                    UpdateReportGSWindow window = new UpdateReportGSWindow();
                    window.ShowInTaskbar = false;
                    window.Owner         = this;
                    window.GetValues(report);
                    window.ShowDialog();
                    SearchReportGS();
                }
                else
                {
                    MessageBox.Show("请选择编辑条目!", "操作提示");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常(Edit):\n" + ex.Message);
            }
        }
 /// <summary>
 /// 双击编辑报表 甘肃
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dataGridGS_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (!Global.EachDistrict.Equals("GS"))
     {
         clsReportGS report;
         try
         {
             if (dataGridGS.SelectedItems.Count > 0)
             {
                 report = (clsReportGS)dataGridGS.SelectedItems[0];
                 //根据主表ID查询子表样品信息集合
                 DataTable dt = _resultTable.GetReportDetailGS(report.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++)
                     {
                         DYSeriesDataSet.DataModel.clsReportGS.ReportDetail reportDetail = new DYSeriesDataSet.DataModel.clsReportGS.ReportDetail();
                         reportDetail.ID                 = ItemNames[i].ID;
                         reportDetail.ReportGSID         = ItemNames[i].ReportGSID;
                         reportDetail.ProjectName        = ItemNames[i].ProjectName;
                         reportDetail.InspectionStandard = ItemNames[i].InspectionStandard;
                         reportDetail.IndividualResults  = ItemNames[i].IndividualResults;
                         reportDetail.Unit               = ItemNames[i].Unit;
                         reportDetail.IndividualDecision = ItemNames[i].IndividualDecision;
                         report.reportDetailList.Add(reportDetail);
                     }
                 }
                 UpdateReportGSWindow window = new UpdateReportGSWindow();
                 window.ShowInTaskbar = false;
                 window.Owner         = this;
                 window.GetValues(report);
                 window.ShowDialog();
                 SearchReportGS();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("异常(Edit):\n" + ex.Message);
         }
     }
 }