Exemple #1
0
        /// <summary>
        /// 通过scanname showname 获取,加载数据的时候,两个值相等
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private Hashtable getItemDictRowByScanName(string data)
        {
            Hashtable ht = new Hashtable();

            int       count           = 0;
            string    centercode      = "";
            string    firstCenterCode = "";
            string    showname        = "";
            DataTable dtItemDict      = null;
            //改成存储过程
            DataSet ds = new Business.ItemProcess().GetItemDict(this.frcode, data);

            if (ds.Tables.Count > 0)
            {
                dtItemDict = ds.Tables[0];
                if (dtItemDict.Rows.Count > 0)
                {
                    DataRow dr = dtItemDict.Rows[0];
                    centercode = dr["centercode"] == null ? "" : dr["centercode"].ToString();
                    showname   = dr["showname"] == null ? "" : dr["showname"].ToString();
                    if (!String.IsNullOrEmpty(centercode))
                    {
                        if (String.IsNullOrEmpty(firstCenterCode))
                        {
                            firstCenterCode = centercode;
                        }
                    }
                }
            }



            if (!String.IsNullOrEmpty(firstCenterCode))
            {
                DataSet dsDict = new Business.DictProcess().GetItemByID(firstCenterCode);
                if (dsDict.Tables.Count > 0)
                {
                    DataTable dtDict = dsDict.Tables[0];
                    if (dtDict.Rows.Count > 0)
                    {
                        ScanDataSet.CenterDataRow centerDataRow = (ScanDataSet.CenterDataRow)dtDict.Rows[0];
                        ht.Add("row", centerDataRow);


                        return(ht);
                    }
                }
            }

            return(ht);
        }
Exemple #2
0
        private Hashtable getItemDictRowByKeyWord(string data)
        {
            Hashtable ht = new Hashtable();

            string centercode      = "";
            string firstCenterCode = "";


            DataTable dtItemDict = new Business.DictProcess().GetItemDictByKeyWord(data).Tables[0];

            if (dtItemDict.Rows.Count > 0)
            {
                for (int i = 0; i < dtItemDict.Rows.Count; i++)
                {
                    DataRow dr = dtItemDict.Rows[i];
                    if (data.IndexOf(dr["keyword"].ToString()) > -1)
                    {
                        centercode = dr["centercode"] == null ? "" : dr["centercode"].ToString();
                        if (!String.IsNullOrEmpty(centercode))
                        {
                            if (String.IsNullOrEmpty(firstCenterCode))
                            {
                                firstCenterCode = centercode;
                            }
                        }
                    }
                }
            }

            if (!String.IsNullOrEmpty(firstCenterCode))
            {
                DataSet dsDict = new Business.DictProcess().GetItemByID(firstCenterCode);
                if (dsDict.Tables.Count > 0)
                {
                    DataTable dtDict = dsDict.Tables[0];
                    if (dtDict.Rows.Count > 0)
                    {
                        ScanDataSet.CenterDataRow centerDataRow = (ScanDataSet.CenterDataRow)dtDict.Rows[0];
                        ht.Add("row", centerDataRow);


                        return(ht);
                    }
                }
            }

            return(ht);
        }
Exemple #3
0
        //一键对照
        private void MapDictForNull()
        {
            if (this.ScanDataGridView.Rows.Count > 1)
            {
                for (int i = 0; i < this.ScanDataGridView.Rows.Count; i++)
                {
                    string centercode = this.ScanDataGridView.Rows[i].Cells["centercode"].Value == null ? "" : this.ScanDataGridView.Rows[i].Cells["centercode"].Value.ToString();

                    if (String.IsNullOrEmpty(centercode))
                    {
                        string    name    = this.ScanDataGridView.Rows[i].Cells["nameDataGridViewTextBoxColumn"].Value == null ? "" : this.ScanDataGridView.Rows[i].Cells["nameDataGridViewTextBoxColumn"].Value.ToString();
                        Hashtable htFirst = getItemDictRowByScanName(name);
                        if (htFirst.Count > 0)
                        {
                            ScanDataSet.CenterDataRow centerRow = (ScanDataSet.CenterDataRow)htFirst["row"];
                            centercode = centerRow.Code;
                            this.ScanDataGridView.Rows[i].Cells["centercode"].Value = centerRow.Code;
                            this.ScanDataGridView.Rows[i].Cells["centername"].Value = centerRow.Name;
                            this.ScanDataGridView.Rows[i].Cells["FeeType"].Value    = centerRow.FeeType;
                            this.ScanDataGridView.Rows[i].Cells["ItemType"].Value   = centerRow.ItemType;
                        }

                        if (String.IsNullOrEmpty(centercode))
                        {
                            //取关键字like
                            Hashtable ht = getItemDictRowByKeyWord(name);
                            if (ht.Count > 0)
                            {
                                ScanDataSet.CenterDataRow centerRow = (ScanDataSet.CenterDataRow)htFirst["row"];

                                this.ScanDataGridView.Rows[i].Cells["centercode"].Value = centerRow.Code;
                                this.ScanDataGridView.Rows[i].Cells["centername"].Value = centerRow.Name;
                                this.ScanDataGridView.Rows[i].Cells["FeeType"].Value    = centerRow.FeeType;
                                this.ScanDataGridView.Rows[i].Cells["ItemType"].Value   = centerRow.ItemType;
                            }
                        }
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 获取单元格(名称)编辑之后的数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ScanDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (this.ScanDataGridView.Columns[e.ColumnIndex].Name == "nameDataGridViewTextBoxColumn")
            {
                this.endName   = this.ScanDataGridView.CurrentCell.Value == null ? "" : this.ScanDataGridView.CurrentCell.Value.ToString();
                this.beginName = this.ScanDataGridView.CurrentRow.Cells["oldName"].Value == null ? "" : this.ScanDataGridView.CurrentRow.Cells["oldName"].Value.ToString();


                //编辑项目名称之后  再次获取对照关系
                Hashtable htFirst = getItemDictRowByScanName(this.endName);
                if (htFirst.Count > 0)
                {
                    ScanDataSet.CenterDataRow centerRow = (ScanDataSet.CenterDataRow)htFirst["row"];
                    this.ScanDataGridView.Rows[e.RowIndex].Cells["CenterCode"].Value = centerRow.Code;
                    this.ScanDataGridView.Rows[e.RowIndex].Cells["CenterName"].Value = centerRow.Name;
                    this.ScanDataGridView.Rows[e.RowIndex].Cells["ItemType"].Value   = centerRow.ItemType;
                    this.ScanDataGridView.Rows[e.RowIndex].Cells["FeeType"].Value    = centerRow.FeeType;

                    //if (!String.IsNullOrEmpty(this.beginName) && !String.IsNullOrEmpty(this.endName))
                    //{
                    //    new Business.ItemProcess().UpdateItemDictRelation(this.beginName, this.endName, centerRow.Code, frcode);

                    //}
                }
                else
                {
                    Hashtable ht = getItemDictRowByKeyWord(this.endName);
                    if (ht.Count > 0)
                    {
                        ScanDataSet.CenterDataRow centerRow = (ScanDataSet.CenterDataRow)ht["row"];
                        this.ScanDataGridView.Rows[e.RowIndex].Cells["CenterCode"].Value = centerRow.Code;
                        this.ScanDataGridView.Rows[e.RowIndex].Cells["CenterName"].Value = centerRow.Name;
                        this.ScanDataGridView.Rows[e.RowIndex].Cells["ItemType"].Value   = centerRow.ItemType;
                        this.ScanDataGridView.Rows[e.RowIndex].Cells["FeeType"].Value    = centerRow.FeeType;
                        //if (!String.IsNullOrEmpty(this.beginName) && !String.IsNullOrEmpty(this.endName))
                        //{
                        //    new Business.ItemProcess().UpdateItemDictRelation(this.beginName, this.endName, centerRow.Code, frcode);
                    }
                }



                string newCentercode = this.ScanDataGridView.Rows[e.RowIndex].Cells["CenterCode"].Value == null ? "" : this.ScanDataGridView.Rows[e.RowIndex].Cells["CenterCode"].Value.ToString();
                if (!String.IsNullOrEmpty(this.beginName) && !String.IsNullOrEmpty(this.endName) && String.IsNullOrEmpty(newCentercode))//没有取到对照关系也保存一份,
                {
                    if (!String.IsNullOrEmpty(this.beginName) && !String.IsNullOrEmpty(this.endName))
                    {
                        new Business.ItemProcess().UpdateItemDictRelation(this.beginName, this.endName, "", frcode);
                    }
                }


                //中心编码不为空  更新对照关系
                if (!String.IsNullOrEmpty(this.beginName) && !String.IsNullOrEmpty(this.endName) && !String.IsNullOrEmpty(newCentercode))
                {
                    new Business.ItemProcess().UpdateItemDictRelation(this.beginName, this.endName, newCentercode, frcode);
                }
            }

            //删除中心名称 清空中心编码
            if (this.ScanDataGridView.Columns[e.ColumnIndex].Name == "CenterName")
            {
                if (this.ScanDataGridView.CurrentCell.Value == DBNull.Value)
                {
                    this.ScanDataGridView.CurrentRow.Cells["centercode"].Value = null;
                }
            }
        }