private void BandingDgvInputStorage()
        {
            try
            {

                dataAcess = new DataAccess();
                dataAcess.Open();
                GetData getData = new GetData(dataAcess.Connection);
                //DataTable dtCompany = getData.GetSingleTable("TC_COMPANY");
                //string companyName = string.Empty;
                //if (dtCompany != null && dtCompany.Rows.Count > 0)
                //{
                //    companyName = dtCompany.Rows[0]["company_name"].ToString();
                //}
                //else
                //{
                //    MessageBox.Show("请先输入公司基本信息!", "公司名称:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return;
                //}

                //labTitle.Text = companyName + "入库单汇总表";
                SearchParameter sp = new SearchParameter();
                sp.SetValue(":INPUT_INSTORAGE_DATE_FROM", dateInputDateFrom.Value.Date);
                sp.SetValue(":INPUT_INSTORAGE_DATE_TO", dateInputDateTo.Value.Date);
                DataTable dtInputStorage = getData.GetTableBySqlStr(Constants.SqlStr.TC_INPUT_STORAGE_LEFTJOIN_GOODS, sp);

                if (dtInputStorage == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (dtInputStorage.Rows.Count > 0)
                {
                    GetDgvInputStorage(dtInputStorage);
                    //添加序列号
                    int countNumber = 0;
                    dtDgvInputStorage.Columns.Add("num", typeof(int));
                    for (int i = 0; i < dtInputStorage.Rows.Count; i++)
                    {
                        dtDgvInputStorage.Rows[i]["num"] = ++countNumber;

                    }
                    dgvInputStorage.DataSource = dtDgvInputStorage;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dataAcess.Close();
            }
        }
        //*******************************************************************
        /// <summary>
        /// 库存查询页面初始化
        /// </summary>
        /// <history>
        ///     完成信息:吴小科      2010/07/26 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void InventorySelectForm_Load(object sender, EventArgs e)
        {
            try
            {
                //打开数据库
                dataAccess = new DataAccess();
                dataAccess.Open();
                //获取操作类
                GetData         getData = new GetData(dataAccess.Connection);
                SearchParameter sp      = new SearchParameter();
                sp.SetValue(":input_instorage_date_FROM", dateInputDateFrom.Value.Date);
                sp.SetValue(":input_instorage_date_TO", dateInputDateTo.Value.Date);
                //获取绑定数据表
                dtStorage = getData.GetTableBySqlStr(Constants.SqlStr.tc_storage_count, sp);

                if (dtStorage == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                DataRow[] drs = dtStorage.Select("input_count=0");
                for (int i = 0; i < drs.Length; i++)
                {
                    dtStorage.Rows.Remove(drs[i]);
                }

                //添加序列号和有效期至
                int countNumber = 0;
                dtStorage.Columns.Add("num", typeof(int));
                dtStorage.Columns.Add("goodsValidity", typeof(DateTime));
                for (int i = 0; i < dtStorage.Rows.Count; i++)
                {
                    dtStorage.Rows[i]["num"] = ++countNumber;
                    int      validity      = int.Parse(dtStorage.Rows[i]["goods_validity"].ToString());
                    DateTime goodSValidity = DateTime.Parse(dtStorage.Rows[i]["input_maketime"].ToString()).AddMonths(validity);
                    dtStorage.Rows[i]["goodsValidity"] = goodSValidity;
                }
                dataGridView_storage.AutoGenerateColumns = false;
                //绑定数据
                dataGridView_storage.DataSource = dtStorage;

                textBox_input_code.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {   //关闭数据库
                dataAccess.Close();
            }
        }
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:代国明      2010/07/23 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BandingDgvOutputStorage()
        {
            try
            {
                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //取得操作类
                GetData getData = new GetData(dataAccess.Connection);

                //初始化参数
                SearchParameter sp = new SearchParameter();

                //赋值
                sp.SetValue(":CONDITION1", "");
                sp.SetValue(":CONDITION2", "");

                //根据条件检索表
                DataTable dtOutputStorage = getData.GetTableByDiyCondition(Constants.SqlStr.TC_OUTPUT_STORAGE_LEFTJOIN_TC_INPUT_STORAGE_LEFTJOIN_TC_GOODS_LEFTJOIN_TC_MAKER, sp);

                //如果为null,弹出错误
                if (dtOutputStorage == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                //dtPrint = dtOutputStorage.Copy();

                //如果不为空,绑定数据源
                if (dtOutputStorage.Rows.Count > 0)
                {
                    //添加序列号
                    int countNumber = 0;
                    dtOutputStorage.Columns.Add("num", typeof(int));
                    for (int i = 0; i < dtOutputStorage.Rows.Count; i++)
                    {
                        dtOutputStorage.Rows[i]["num"] = ++countNumber;
                    }
                    dgvOutputStorage.DataSource = dtOutputStorage;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
        //判断标示
        private bool updateMark()
        {
            Boolean mark = false;

            dataAccess = new DataAccess();
            try
            {
                SearchParameter sp = new SearchParameter();
                sp.SetValue(":Maintain_input_code", txtMaintain_input_code.Text);
                dataAccess.Open();
                GetData   getData = new GetData(dataAccess.Connection);
                DataTable dt      = getData.GetSingleTableByCondition("TC_MAINTAIN", sp);
                if (dt.Rows.Count > 0)
                {
                    mark = true;
                    return(mark);
                }
                sp.Clear();
                sp.SetValue("input_code", txtMaintain_input_code.Text);
                dataAccess.Open();
                getData = new GetData(dataAccess.Connection);
                dt      = getData.GetSingleTableByCondition("TC_lose", sp);
                if (dt.Rows.Count > 0)
                {
                    mark = true;
                    return(mark);
                }

                dataAccess.Open();
                getData = new GetData(dataAccess.Connection);
                dt      = getData.GetSingleTableByCondition("TC_OUTPUT_STORAGE", sp);
                if (dt.Rows.Count > 0)
                {
                    mark = true;
                    return(mark);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("请查看数据库是否正常!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                throw ex;
            }
            finally
            {
                if (dataAccess.Connection != null)
                {
                    dataAccess.Close();
                }
            }
            return(mark);
        }
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:代国明      2010/07/26 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BindingDgvLose()
        {
            //初始化参数类
            SearchParameter sp = new SearchParameter();

            try
            {
                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //取得操作类
                GetData getData = new GetData(dataAccess.Connection);
                sp.SetValue(":LOSE_DATETIME_FROM", dtp_lose_datetime_Start.Value.Date);
                sp.SetValue(":LOSE_DATETIME_TO", DateTime.Parse(dtp_lose_datetime_End.Value.Date.ToString("yy-MM-dd") + " " + "23:59:59"));
                //根据条件检索表
                DataTable dtLose = getData.GetTableBySqlStr(Constants.SqlStr.TC_LOSE_LEFTJOIN_TC_INPUT_STORAGE_LEFTJOIN_TC_GOODS_LEFTJOIN_TC_MAKER_SELECT, sp);

                //如果为NULL,报错
                if (dtLose == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                //如果不为NULL,绑定数据

                GetDgvLose(dtLose);

                //添加序列号
                int countNumber = 0;
                dtDgvLose.Columns.Add("index", typeof(int));
                for (int i = 0; i < dtDgvLose.Rows.Count; i++)
                {
                    dtDgvLose.Rows[i]["index"] = ++countNumber;
                }

                dgvLose.DataSource = dtDgvLose;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
Beispiel #6
0
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:代国明      2010/07/23 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BindingDgvOutputStorage()
        {
            try
            {
                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //取得操作类
                GetData getData = new GetData(dataAccess.Connection);

                //初始化参数类
                SearchParameter sp = new SearchParameter();

                sp.SetValue(":OUTPUT_INSTORAGE_DATE_FROM", dtp_output_instorage_date_Start.Value.Date);
                sp.SetValue(":OUTPUT_INSTORAGE_DATE_TO", dtp_output_instorage_date_End.Value.Date);
                //根据条件检索表
                DataTable dtInputStorage = getData.GetTableBySqlStr(Constants.SqlStr.TC_OUTPUT_STORAGE_LEFTJOIN_TC_CUSTOMER_LEFTJOIN_TC_INPUT_STORAGE_LEFTJOIN_TC_GOODS_SELECT, sp);

                //如果为NULL,报错
                if (dtInputStorage == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                dtPrint = dtInputStorage.Copy();
                //如果不为NULL,绑定数据
                if (dtInputStorage.Rows.Count > 0)
                {
                    //添加序列号
                    int countNumber = 0;
                    dtInputStorage.Columns.Add("num", typeof(int));
                    for (int i = 0; i < dtInputStorage.Rows.Count; i++)
                    {
                        dtInputStorage.Rows[i]["num"] = ++countNumber;
                    }
                    dgvOutputStorage.DataSource = dtInputStorage;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
        public void BandingDgvCustomer()
        {
            try
            {
                dataAccess = new DataAccess();
                dataAccess.Open();

                GetData getData = new GetData(dataAccess.Connection);

                SearchParameter sp = new SearchParameter();
                sp.SetValue(":customer_flag", "1");

                DataTable dt = getData.GetTableBySqlStr(Constants.SqlStr.TC_CUSTOMER_RIGHTJOIN_TC_ARCHIVES, sp);

                dgvCustomer.AutoGenerateColumns = false;
                dt.Columns.Add("index", typeof(int));
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dt.Rows[i]["index"] = i + 1;
                }
                dgvCustomer.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (dataAccess.Connection != null)
                {
                    dataAccess.Close();
                }
            }
        }
Beispiel #8
0
        //***********************************************************************
        /// <summary>
        /// 获得出库表
        /// </summary>
        /// <return>dtLose</return>
        /// <history>
        ///    完成信息:代国明      2010/07/25 完成
        ///    更新信息:
        /// </history>
        //***********************************************************************
        private DataTable GetOutputStorageTable()
        {
            //取得单表数据
            DataTable dtOutputStorage = null;;

            try
            {
                //添加参数
                SearchParameter sp = new SearchParameter();

                sp.SetValue(":OUTPUT_TYPE", "1");

                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //取得操作类
                GetData getData = new GetData(dataAccess.Connection);

                //取得单表数据
                dtOutputStorage = getData.GetSingleTableByCondition("tc_output_storage", sp);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
            return(dtOutputStorage);
        }
        //***********************************************************************
        /// <summary>
        /// 画面初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        ///    完成信息:吴小科      2010/07/22 完成
        ///    更新信息:
        /// </history>
        //***********************************************************************
        private void sellStorageDialogForm_Load(object sender, EventArgs e)
        {
            //设置参数
            SearchParameter sp = new SearchParameter();

            sp.SetValue(":CONDITION1", "");
            //sp.SetValue(":TC_OUTPUT_STORAGE.OUTPUT_TYPE", "0");
            try
            {
                //打开数据库
                dataAccess = new DataAccess();
                dataAccess.Open();
                //获取操作类
                GetData getData = new GetData(dataAccess.Connection);
                //获取绑定数据表
                DataTable dtOutGoods = getData.GetTableByDiyCondition(Constants.SqlStr.TC_INPUT_STORAGE_LEFTJOIN_OUTPUT_STORAGE2, sp);
                //添加序列号
                int countNumber = 0;
                dtOutGoods.Columns.Add("num", typeof(int));
                for (int i = 0; i < dtOutGoods.Rows.Count; i++)
                {
                    dtOutGoods.Rows[i]["num"] = ++countNumber;
                }
                //绑定数据
                dgvOutput_storage.DataSource = dtOutGoods;
            }
            catch (Exception ex)
            {
                MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {   //关闭数据库
                dataAccess.Close();
            }
        }
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:代国明      2010/07/23 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BandingDgvCustomer()
        {
            try
            {
                dataAccess = new DataAccess();
                dataAccess.Open();

                GetData getData = new GetData(dataAccess.Connection);

                SearchParameter sp = new SearchParameter();
                sp.SetValue(":CUSTOMER_FLAG", "0");

                DataTable dtCounter = getData.GetSingleTableByCondition("TC_CUSTOMER", sp);

                dtCounter.Columns.Add("index", typeof(int));
                for (int i = 0; i < dtCounter.Rows.Count; i++)
                {
                    dtCounter.Rows[i]["index"] = i + 1;
                }


                dgvCustomer.DataSource = dtCounter;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dataAccess.Close();
            }
        }
Beispiel #11
0
        //***********************************************************************
        /// <summary>
        /// 查询按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        ///    完成信息:吴小科      2010/07/16 完成
        ///    更新信息:吴小科      2010/07/22 修改
        /// </history>
        //***********************************************************************
        private void btnSearch_Click(object sender, EventArgs e)
        {
            foreach (Control control in groupBox1.Controls)
            {
                if (control is TextBox)
                {
                    if (Util.CheckRegex(control.Text.Trim()) && !((TextBox)control).ReadOnly)
                    {
                        MessageBox.Show("不可以输入非法字符,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        control.Focus();
                        return;
                    }
                }
            }
            try
            {
                //设置查询条件参数
                SearchParameter sp = new SearchParameter();
                if (textBox_counter_code.Text.Trim() != string.Empty)
                {   //查询条件参数赋值
                    sp.SetValue(":counter_code", textBox_counter_code.Text);
                }
                //打开数据库
                dataAccess = new DataAccess();
                dataAccess.Open();
                //获取操作类
                GetData getData = new GetData(dataAccess.Connection);
                //返回绑定数据表
                DataTable dtCounter = getData.GetSingleTableByCondition("tc_counter", sp);

                if (dtCounter == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                //添加序列号
                int countNum = 0;
                dtCounter.Columns.Add("num", typeof(int));
                for (int i = 0; i < dtCounter.Rows.Count; i++)
                {
                    dtCounter.Rows[i]["num"] = ++countNum;
                }
                //绑定数据
                dataGridView_Counter.DataSource = dtCounter;
                if (dataGridView_Counter.Rows.Count == 0)
                {
                    MessageBox.Show("数据不存在,请查看输入的条件是否正确!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                //关闭数据库
                dataAccess.Close();
            }
        }
Beispiel #12
0
        /// <summary>
        /// 删除按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        ///    完成信息:李梓楠      2010/11/14 完成
        ///    更新信息:
        /// </history>

        private void btnDelete_Click(object sender, EventArgs e)
        {
            result   = -1;
            countNum = 0;
            if (dgv.SelectedRows.Count > 1)
            {
                MessageBox.Show("只能选择一条要删除的记录!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (dgv.SelectedRows.Count < 1)
            {
                MessageBox.Show("请选择一条要删除的记录!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }


            if (MessageBox.Show("您确定要删除该数据吗?", Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                SearchParameter sp = new SearchParameter();

                dataAccess = new DataAccess();
                try
                {
                    dataAccess.Open();
                    dataAccess.BeginTransaction();
                    GetData getData = new GetData(dataAccess.Connection, dataAccess.Transaction);

                    sp.SetValue(":visit_id", dgv.SelectedRows[0].Cells["visit_id"].Value.ToString());
                    result = getData.DeleteRow("tc_visit", sp);
                    dataAccess.Commit();
                }
                catch (Exception ex)
                {
                    dataAccess.Rollback();
                    MessageBox.Show("数据删除时发生错误,请检查数据库!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    throw ex;
                }
                finally
                {
                    dataAccess.Close();
                }
                if (result == 0)
                {
                    MessageBox.Show("数据已经删除!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    BandingDgv();
                }
                else
                {
                    MessageBox.Show("数据删除时发生错误,请检查数据库!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                //设置按钮状态
                dataType = DataType.None;
                setButtonState();
            }
        }
Beispiel #13
0
        //***********************************************************************
        /// <summary>
        /// 添加后库存数目剪掉添加数目数据信息
        /// </summary>
        /// <history>
        ///    完成信息:代国明      2010/07/22 完成
        ///    更新信息:
        /// </history>
        //***********************************************************************
        void UpdateStorageDetailsByAdd()
        {
            try
            {
                result = -1;

                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //打开事务
                dataAccess.BeginTransaction();

                SearchParameter sp = new SearchParameter();

                sp.SetValue(":GOODS_CODE", tempStorageEntity.Goods_code);
                sp.SetValue(":COUNT", tempStorageEntity.Count);

                //取得操作类
                GetData getData = new GetData(dataAccess.Connection, dataAccess.Transaction);

                //取得结果符
                result = getData.UpdateTemp_storage(tempStorageEntity, sp);

                //提交事务
                dataAccess.Commit();
            }
            catch (Exception ex)
            {
                if (dataAccess.Transaction != null)
                {
                    //回滚
                    dataAccess.Rollback();
                }

                //提示错误
                MessageBox.Show("数据添加时发生错误,请检查数据库!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
Beispiel #14
0
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:李梓楠      2010/11/14 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BandingDgv()
        {
            try
            {
                dataAccess = new DataAccess();
                dataAccess.Open();

                GetData getData = new GetData(dataAccess.Connection);

                SearchParameter sp = new SearchParameter();
                if (checkDate.Checked == true)
                {
                    sp.SetValue(":VISIT_DATE_FROM", dateVisitFrom.Value.Date);
                    sp.SetValue(":VISIT_DATE_TO", dateVisitTo.Value.Date);
                }
                DataTable dtCounter = getData.GetTableBySqlStr(Constants.SqlStr.TC_VISIT_JOIN_IN_OUT_CUSTOMER_GOODS, sp);

                dtCounter.Columns.Add("index", typeof(int));
                for (int i = 0; i < dtCounter.Rows.Count; i++)
                {
                    dtCounter.Rows[i]["index"] = i + 1;
                }
                dgv.DataSource = dtCounter;

                dtPrint = dtCounter;
                //使被修改对线变为选中行
                if (dgv != null && dgv.Rows.Count > 0 && countNum != 0)
                {
                    dgv.Rows[0].Selected                = false;
                    dgv.Rows[countNum].Selected         = true;
                    dgv.FirstDisplayedScrollingRowIndex = countNum;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("请查看数据库是否正常!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                throw ex;
            }
            finally
            {
                dataAccess.Close();
            }
        }
        private DataTable LoadMaintenance()
        {
            try
            {
                dataAccess = new DataAccess();
                dataAccess.Open();

                GetData         getData = new GetData(dataAccess.Connection);
                SearchParameter sp      = new SearchParameter();
                sp.SetValue(":maintain_code", htMaintenance["maintain_code"].ToString());
                DataTable dt = getData.GetSingleTableByCondition("tc_maintain_detail", sp);
                //DataTable dtCompany = getData.GetSingleTable("tc_company");
                //if (dtCompany == null || dtCompany.Rows.Count == 0)
                //{
                //    MessageBox.Show("请先填写公司基本信息再进行打印!", "公司信息:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return dt.Clone();
                //}
                //htMaintenance.Add("company_name", "");
                DataTable dtMaintenance = new DataTable();
                //DataSet dsMaintenance = new DataSet();
                dtMaintenance.Columns.Add("maintain_detail_datetime", typeof(string));
                dtMaintenance.Columns.Add("maintain_detail_quality", typeof(string));
                dtMaintenance.Columns.Add("maintain_detail_settle", typeof(string));
                dtMaintenance.Columns.Add("maintain_detail_oper", typeof(string));
                dtMaintenance.Columns.Add("maintain_detail_remark", typeof(string));
                dtMaintenance.Columns.Add("input_batch_num", typeof(string));

                if (dt != null && dt.Rows.Count != 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DataRow dr = dtMaintenance.NewRow();
                        dr["maintain_detail_datetime"] = DateTime.Parse(dt.Rows[i]["maintain_detail_datetime"].ToString()).ToString("yyyy-MM-dd");
                        dr["maintain_detail_quality"]  = dt.Rows[i]["maintain_detail_quality"].ToString();
                        dr["maintain_detail_settle"]   = dt.Rows[i]["maintain_detail_settle"].ToString();
                        dr["maintain_detail_oper"]     = dt.Rows[i]["maintain_detail_oper"].ToString();
                        dr["maintain_detail_remark"]   = dt.Rows[i]["maintain_detail_remark"].ToString();
                        dr["input_batch_num"]          = htMaintenance["input_batch_num"];

                        dtMaintenance.Rows.Add(dr);
                    }
                }

                return(dtMaintenance);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(null);
            }
            finally
            {
                dataAccess.Close();
            }
        }
Beispiel #16
0
        //双击选择出库编号
        private void txtApparatus_quality_output_code_DoubleClick(object sender, EventArgs e)
        {
            if (dataType == DataType.Insert)
            {
                sellStorageDialogForm child = new sellStorageDialogForm();
                child.ShowDialog();
                int sum = 0;
                if (child.outputCode != string.Empty)
                {
                    try
                    {
                        SearchParameter sp = new SearchParameter();

                        sp.SetValue(":apparatus_output_code", child.outputCode);

                        dataAccess = new DataAccess();
                        dataAccess.Open();

                        GetData   getData = new GetData(dataAccess.Connection);
                        DataTable dt      = getData.GetTableBySqlStr(Constants.SqlStr.SUM_TC_APPARATUS_QUALITY, sp);
                        if (dt != null && dt.Rows.Count != 0 && dt.Rows[0]["suncount"].ToString() != string.Empty)
                        {
                            sum = int.Parse(dt.Rows[0]["suncount"].ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        throw ex;
                    }
                    finally
                    {
                        dataAccess.Close();
                    }

                    txtApparatus_quality_output_code.Text = child.outputCode;
                    txtApparatus_goods_name.Text          = child.goodsName;
                    txtApparatus_supplier_name.Text       = child.supplierName;
                    txtApparatus_customer_name.Text       = child.customerName;
                    outputInstorageDate = child.outputInstorageDate;

                    int i = child.lastCount - sum;
                    labelSellcount.Text = i.ToString();
                    if (dataType == DataType.Update)
                    {
                        labelSellcount.Text = (i + int.Parse(dgv.SelectedRows[0].Cells["apparatus_quality_count"].Value.ToString())).ToString();
                    }
                }
            }
            else
            {
                return;
            }
        }
        //***********************************************************************
        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <history>
        ///    完成信息:代国明      2010/07/20 完成
        ///    更新信息:
        /// </history>
        //***********************************************************************
        public void BindingDgv()
        {
            try
            {
                //初始化参数类
                SearchParameter sp = new SearchParameter();

                sp.SetValue(":(ISNULL(TC_INPUT_STORAGE.INPUT_STANDARD_COUNT, 0)-ISNULL(DERIVEDTBL_2.LOSE_COUNT, 0)-ISNULL(DERIVEDTBL_1.OUTPUT_COUNT,0))!", 0);

                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //取得操作类
                GetData getData = new GetData(dataAccess.Connection);

                //根据条件检索单表
                DataTable dtStorageGoods = getData.GetTableBySqlStr(Constants.SqlStr.TC_INPUT_STORAGE_LEFTJOIN_TC_OUTPUT_STORAGE_LEFTJOIN_TC_GOODS, sp);

                //如果为NULL,报错
                if (dtStorageGoods == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (dtStorageGoods.Rows.Count > 0)
                {
                    GetDgvStorageGoods(dtStorageGoods);
                    //dtStorageGoods.Columns.Add("index", typeof(int));
                    //for (int i = 0; i < dtStorageGoods.Rows.Count; i++)
                    //{
                    //    dtStorageGoods.Rows[i]["index"] = i + 1;
                    //}

                    dgvStorageGoods.DataSource = dtDgvStorageGoods;
                }

                if (dgvStorageGoods != null && dgvStorageGoods.Rows.Count > 0 && countNum != 0)
                {
                    dgvStorageGoods.Rows[0].Selected        = false;
                    dgvStorageGoods.Rows[countNum].Selected = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
Beispiel #18
0
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:代国明      2010/07/13 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BandingDgvOutput_Storage()
        {
            //初始化参数类
            SearchParameter sp = new SearchParameter();

            sp.SetValue(":OS.OUTPUT_TYPE", '0');

            try
            {
                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //取得操作类
                GetData getData = new GetData(dataAccess.Connection);

                //取得单表数据
                dtOutputStorage = getData.GetTableBySqlStr(Constants.SqlStr.TC_OUTPUT_STORAGE_LEFTJOIN_TC_CUSTOMER_LEFTJOIN_TC_INPUT_STORAGE_LEFTJOIN_TC_GOODS, sp);

                //如果为NULL,报错
                if (dtOutputStorage == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                //添加序列号
                int countNumber = 0;
                dtOutputStorage.Columns.Add("index", typeof(int));
                for (int i = 0; i < dtOutputStorage.Rows.Count; i++)
                {
                    dtOutputStorage.Rows[i]["index"] = ++countNumber;
                }

                this.dgvOutput_storage.DataSource = dtOutputStorage;

                if (dgvOutput_storage != null && dgvOutput_storage.Rows.Count > 0 && countNum != 0)
                {
                    dgvOutput_storage.Rows[0].Selected        = false;
                    dgvOutput_storage.Rows[countNum].Selected = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
Beispiel #19
0
        //***********************************************************************
        /// <summary>
        /// 更新按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        ///    完成信息:吴小科      2010/07/13 完成
        ///    更新信息:
        /// </history>
        //***********************************************************************
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //如果选择多条数据,提示
            if (dataGridView_input_storage.SelectedRows.Count > 1)
            {
                MessageBox.Show("只能选择一条要修改的记录!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //如过画面中不存在数据,提示
            if (dataGridView_input_storage.SelectedRows.Count < 1)
            {
                MessageBox.Show("请选择一条要修改的记录!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //设置查询条件参数
            SearchParameter sp2 = new SearchParameter();

            sp2.SetValue(":TC_INPUT_STORAGE.INPUT_TYPE", '0');
            sp2.SetValue(":TC_INPUT_STORAGE.INPUT_CODE", textBox_input_code2.Text);
            //打开数据库
            dataAccess = new DataAccess();
            dataAccess.Open();
            //获取操作类
            GetData getData = new GetData(dataAccess.Connection);
            //返回绑定数据表
            DataTable dtCondition = getData.GetTableBySqlStr(Constants.SqlStr.TC_INPUT_INIT_STORAGE_LEFTJOIN_GOODS, sp2);

            if (dtCondition.Rows[0]["operate_type"].ToString() == "1")
            {
                MessageBox.Show("该入库单已经存在销售或报损记录,不能修改或删除!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //获取原先数据和行号
            oldCount = Convert.ToInt32(dataGridView_input_storage.SelectedRows[0].Cells["input_standard_count"].Value.ToString());
            countNum = dataGridView_input_storage.SelectedRows[0].Index;
            dataType = DataType.Update;
            SetButtonState();
        }
Beispiel #20
0
        //***********************************************************************
        /// <summary>
        /// 删除后复原库存数目数据信息
        /// </summary>
        /// <history>
        ///    完成信息:代国明      2010/07/22 完成
        ///    更新信息:
        /// </history>
        //***********************************************************************
        void UpdateStorageDetailsbyDelete()
        {
            //取得树体类
            tempStorageEntity = new EntityTemp_storage();

            //赋值实体类
            tempStorageEntity.Goods_code = dgvOutputStorage.SelectedRows[0].Cells["input_goods_code"].Value.ToString();
            tempStorageEntity.Count      = Convert.ToInt32(dgvOutputStorage.SelectedRows[0].Cells["output_count"].Value.ToString());

            try
            {
                result = -1;

                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //打开事务
                dataAccess.BeginTransaction();

                SearchParameter sp = new SearchParameter();

                sp.SetValue(":goods_code", tempStorageEntity.Goods_code);

                //取得操作类
                GetData getData = new GetData(dataAccess.Connection, dataAccess.Transaction);

                //取得结果符
                result = getData.UpdateTemp_storage(tempStorageEntity, sp);

                //提交事务
                dataAccess.Commit();
            }
            catch (Exception ex)
            {
                if (dataAccess.Transaction != null)
                {
                    //回滚
                    dataAccess.Rollback();
                }

                //提示错误
                MessageBox.Show("数据添加时发生错误,请检查数据库!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
Beispiel #21
0
        private void BandingDgvRecordValidate()
        {
            try
            {
                dataAcess = new DataAccess();
                dataAcess.Open();
                GetData getData = new GetData(dataAcess.Connection);

                SearchParameter sp = new SearchParameter();

                sp.SetValue(":CONDITION1", " WHERE TC_INPUT_STORAGE.INPUT_TYPE <> 0 and  TC_INPUT_STORAGE.INPUT_CHECKTIME >= '" + dtp_input_checktime_Start.Value.Date + "' and TC_INPUT_STORAGE.INPUT_CHECKTIME <= '" + DateTime.Parse(dtp_input_checktime_End.Value.Date.ToString("yyyy-MM-dd") + " " + "23:59:59") + "' ");

                DataTable dtRecordValidate = getData.GetTableByDiyCondition(Constants.SqlStr.TC_INPUT_STORAGE_LEFTJOIN_GOODS_SELECTRECORDVALIDATE, sp);

                if (dtRecordValidate == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }


                dtPrint = dtRecordValidate;

                dtRecordValidate.Columns.Add("sn_sl");

                for (int i = 0; i < dtRecordValidate.Rows.Count; i++)
                {
                    string sn_sl = dtRecordValidate.Rows[i]["supplier_name"].ToString() + "(" + dtRecordValidate.Rows[i]["supplier_licence"].ToString() + ")";
                    dtRecordValidate.Rows[i]["sn_sl"] = sn_sl;
                }

                //添加序列号
                int countNumber = 0;
                dtRecordValidate.Columns.Add("index", typeof(int));
                for (int i = 0; i < dtRecordValidate.Rows.Count; i++)
                {
                    dtRecordValidate.Rows[i]["index"] = ++countNumber;
                }

                dgvRecordValidate.DataSource = dtRecordValidate;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dataAcess.Close();
            }
        }
Beispiel #22
0
        /// <summary>
        /// 修改按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        ///    完成信息:李梓楠      2010/7/26 完成
        ///    更新信息:
        /// </history>

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (dgv.SelectedRows.Count > 1)
            {
                MessageBox.Show("只能选择一条要修改的记录!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (dgv.SelectedRows.Count < 1)
            {
                MessageBox.Show("请选择一条要修改的记录!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //可填数量
            int i   = 0;
            int sum = 0;

            i = int.Parse(dgv.SelectedRows[0].Cells["output_count"].Value.ToString());
            try
            {
                SearchParameter sp = new SearchParameter();

                sp.SetValue(":apparatus_output_code", dgv.SelectedRows[0].Cells["apparatus_quality_output_code"].Value.ToString());

                dataAccess = new DataAccess();
                dataAccess.Open();

                GetData   getData = new GetData(dataAccess.Connection);
                DataTable dt      = getData.GetTableBySqlStr(Constants.SqlStr.SUM_TC_APPARATUS_QUALITY, sp);
                if (dt != null && dt.Rows.Count != 0 && dt.Rows[0]["suncount"].ToString() != string.Empty)
                {
                    sum = int.Parse(dt.Rows[0]["suncount"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw ex;
            }
            finally
            {
                dataAccess.Close();
            }
            i = i - sum + int.Parse(dgv.SelectedRows[0].Cells["apparatus_quality_count"].Value.ToString());
            labelSellcount.Text = i.ToString();
            dataType            = DataType.Update;
            setButtonState();
            txtApparatus_quality_output_code.Focus();
        }
Beispiel #23
0
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:代国明      2010/08/03 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BindingDgvLose()
        {
            try
            {
                //初始化参数类
                SearchParameter sp = new SearchParameter();

                sp.SetValue(":CONDITION1", "");
                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //取得操作类
                GetData getData = new GetData(dataAccess.Connection);

                //根据条件检索表
                DataTable dtSystemLog = getData.GetTableByDiyCondition(Constants.SqlStr.TC_SYSTEM_LOG, sp);

                //如果为NULL,报错
                if (dtSystemLog == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                //如果为零,显示没有数据
                if (dtSystemLog.Rows.Count == 0)
                {
                    MessageBox.Show("数据不存在,请查看输入的条件是否正确!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                //如果不为NULL,绑定数据
                if (dtSystemLog.Rows.Count > 0)
                {
                    dgvSystemLog.DataSource = dtSystemLog;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
Beispiel #24
0
        private void SystemLogForm_Load(object sender, EventArgs e)
        {
            dgvSystemLog.AllowUserToOrderColumns = false;

            try
            {
                //初始化参数类
                SearchParameter sp = new SearchParameter();

                sp.SetValue(":CONDITION1", "");
                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //取得操作类
                GetData getData = new GetData(dataAccess.Connection);

                //根据条件检索表
                DataTable dtSystemLog = getData.GetTableByDiyCondition(Constants.SqlStr.TC_SYSTEM_LOG, sp);

                //如果为NULL,报错
                if (dtSystemLog == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                dtSystemLog.Columns.Add("index");

                for (int i = 0; i < dtSystemLog.Rows.Count; i++)
                {
                    dtSystemLog.Rows[i]["index"] = i + 1;
                }

                dgvSystemLog.DataSource = dtSystemLog;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
Beispiel #25
0
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:吴小科      2010/07/13 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BandingDgvCounter()
        {
            try
            {
                //打开数据库
                dataAccess = new DataAccess();
                dataAccess.Open();
                //获取操作类
                GetData getData = new GetData(dataAccess.Connection);
                //设置加载条件
                SearchParameter sp = new SearchParameter();
                sp.SetValue(":input_type", '0');
                //获取绑定数据表
                DataTable dtInput_storage = getData.GetTableBySqlStr(Constants.SqlStr.TC_INPUT_INIT_STORAGE_LEFTJOIN_GOODS, sp);
                //添加序列号
                int countNumber = 0;
                dtInput_storage.Columns.Add("num", typeof(int));
                for (int i = 0; i < dtInput_storage.Rows.Count; i++)
                {
                    dtInput_storage.Rows[i]["num"] = ++countNumber;
                }
                //绑定数据
                dataGridView_input_storage.DataSource = dtInput_storage;

                if (dataGridView_input_storage != null && dataGridView_input_storage.Rows.Count > 0 && countNum != 0)
                {
                    dataGridView_input_storage.Rows[0].Selected                = false;
                    dataGridView_input_storage.Rows[countNum].Selected         = true;
                    dataGridView_input_storage.FirstDisplayedScrollingRowIndex = countNum;
                }
                if (dataGridView_input_storage.Rows.Count == 0)
                {
                    dataGridClear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:李梓楠      2010/7/15 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BandingDgv()
        {
            try
            {
                dataAccess = new DataAccess();
                dataAccess.Open();

                GetData getData = new GetData(dataAccess.Connection);

                SearchParameter sp = new SearchParameter();
                sp.SetValue(":authority_level", "2");
                DataTable dtCounter = getData.GetTableBySqlStr(Constants.SqlStr.tc_AUTHORITY_LEFTJOIN_STAFF, sp);;

                dgv.AutoGenerateColumns = false;
                dtCounter.Columns.Add("index", typeof(int));
                for (int i = 0; i < dtCounter.Rows.Count; i++)
                {
                    dtCounter.Rows[i]["index"] = i + 1;
                }
                dgv.DataSource = dtCounter;

                //使被修改对线变为选中行
                if (dgv != null && dgv.Rows.Count > 0 && countNum != 0)
                {
                    dgv.Rows[0].Selected                = false;
                    dgv.Rows[countNum].Selected         = true;
                    dgv.FirstDisplayedScrollingRowIndex = countNum;
                }
                if (LoginUser.UserAuthority == "0")
                {
                    btnRepassword.Text = "初始化管理员密码";
                    btnUpdate.Text     = "修改药监局密码";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据查询时发生错误,请检查数据库!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                throw ex;
            }
            finally
            {
                dataAccess.Close();
            }
        }
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:李梓楠      2010/11/8 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BandingDgv()
        {
            try
            {
                dataAccess = new DataAccess();
                dataAccess.Open();

                GetData getData = new GetData(dataAccess.Connection);

                SearchParameter sp = new SearchParameter();
                sp.SetValue(":customer_flag", "1");

                DataTable dt = getData.GetTableBySqlStr(Constants.SqlStr.TC_CUSTOMER_RIGHTJOIN_TC_ARCHIVES, sp);

                dgv.AutoGenerateColumns = false;
                dt.Columns.Add("index", typeof(int));
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dt.Rows[i]["index"] = i + 1;
                }
                dgv.DataSource = dt;

                //使被修改对线变为选中行
                if (dgv != null && dgv.Rows.Count > 0 && countNum != 0)
                {
                    dgv.Rows[0].Selected                = false;
                    dgv.Rows[countNum].Selected         = true;
                    dgv.FirstDisplayedScrollingRowIndex = countNum;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据加载时发生错误,请检查数据库!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

                throw ex;
            }
            finally
            {
                dataAccess.Close();
            }
        }
Beispiel #28
0
 //*******************************************************************
 /// <summary>
 /// 入库页面初始化
 /// </summary>
 /// <history>
 ///     完成信息:吴小科      2010/07/13 完成
 ///     更新信息:
 /// </history>
 //*******************************************************************
 private void InitStorageForm_Load(object sender, EventArgs e)
 {
     try
     {
         //打开数据库
         dataAccess = new DataAccess();
         dataAccess.Open();
         //获取操作类
         GetData getData = new GetData(dataAccess.Connection);
         //设置加载条件
         SearchParameter sp = new SearchParameter();
         sp.SetValue(":input_type", '0');
         //获取绑定数据表
         DataTable dtInput_storage = getData.GetTableBySqlStr(Constants.SqlStr.TC_INPUT_INIT_STORAGE_LEFTJOIN_GOODS, sp);
         //添加序列号
         int countNumber = 0;
         dtInput_storage.Columns.Add("num", typeof(int));
         for (int i = 0; i < dtInput_storage.Rows.Count; i++)
         {
             dtInput_storage.Rows[i]["num"] = ++countNumber;
         }
         //绑定数据
         dataGridView_input_storage.DataSource = dtInput_storage;
         if (dataGridView_input_storage != null && dataGridView_input_storage.Rows.Count > 0 && countNum != 0)
         {
             dataGridView_input_storage.Rows[0].Selected        = false;
             dataGridView_input_storage.Rows[countNum].Selected = true;
         }
         //设定按钮状态
         SetButtonState();
         textBox_input_code.Focus();
     }
     catch (Exception ex)
     {
         MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     finally
     {   //关闭数据库
         dataAccess.Close();
     }
 }
Beispiel #29
0
        //private void GetDgvInputStorage(DataTable dt)
        //{
        //    dtDgvInputStorage = new DataTable();
        //    dtDgvInputStorage.Columns.Add("input_code", typeof(string));
        //    dtDgvInputStorage.Columns.Add("input_type", typeof(string));
        //    dtDgvInputStorage.Columns.Add("goods_name", typeof(string));
        //    dtDgvInputStorage.Columns.Add("goods_type", typeof(string));
        //    dtDgvInputStorage.Columns.Add("supplier_name", typeof(string));
        //    dtDgvInputStorage.Columns.Add("maker_name", typeof(string));
        //    dtDgvInputStorage.Columns.Add("input_standard_count", typeof(string));
        //    dtDgvInputStorage.Columns.Add("input_batch_num", typeof(string));
        //    dtDgvInputStorage.Columns.Add("input_instorage_date", typeof(string));
        //    dtDgvInputStorage.Columns.Add("input_maketime", typeof(string));
        //    dtDgvInputStorage.Columns.Add("goods_validity", typeof(string));
        //    dtDgvInputStorage.Columns.Add("input_check_persion", typeof(string));
        //    dtDgvInputStorage.Columns.Add("input_checktime", typeof(string));

        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        DataRow dr = dtDgvInputStorage.NewRow();
        //        dr["input_code"] = dt.Rows[i]["input_code"].ToString();
        //        if (dt.Rows[i]["input_type"].ToString().Equals("0"))
        //        {
        //            dr["input_type"] = "初始入库";
        //        }
        //        else if (dt.Rows[i]["input_type"].ToString().Equals("1"))
        //        {
        //            dr["input_type"] = "购货入库";
        //        }
        //        else if (dt.Rows[i]["input_type"].ToString().Equals("2"))
        //        {
        //            dr["input_type"] = "赠品入库";
        //        }
        //        else if (dt.Rows[i]["input_type"].ToString().Equals("3"))
        //        {
        //            dr["input_type"] = "退货入库";
        //        }

        //        dr["goods_name"] = dt.Rows[i]["goods_name"].ToString();
        //        dr["goods_type"] = dt.Rows[i]["goods_type"].ToString();
        //        dr["supplier_name"] = dt.Rows[i]["supplier_name"].ToString();
        //        dr["maker_name"] = dt.Rows[i]["maker_name"].ToString();
        //        dr["input_standard_count"] = dt.Rows[i]["input_standard_count"].ToString();
        //        dr["input_batch_num"] = dt.Rows[i]["input_batch_num"].ToString();
        //        dr["input_instorage_date"] = DateTime.Parse(dt.Rows[i]["input_instorage_date"].ToString()).ToString("yyyy-MM-dd");
        //        dr["input_maketime"] = DateTime.Parse(dt.Rows[i]["input_maketime"].ToString()).ToString("yyyy-MM-dd");
        //        dr["goods_validity"] = dt.Rows[i]["goods_validity"].ToString();
        //        dr["input_check_persion"] = dt.Rows[i]["input_check_persion"].ToString();
        //        if (dt.Rows[i]["input_checktime"].ToString().Equals(string.Empty))
        //        {
        //            dr["input_checktime"] = "";
        //        }
        //        else
        //        {
        //            dr["input_checktime"] = DateTime.Parse(dt.Rows[i]["input_checktime"].ToString()).ToString("yyyy-MM-dd");
        //        }

        //        dtDgvInputStorage.Rows.Add(dr);
        //    }
        //}

        private void BandingDgvInputStorage()
        {
            try
            {
                dataAcess = new DataAccess();
                dataAcess.Open();
                GetData getData = new GetData(dataAcess.Connection);

                SearchParameter sp = new SearchParameter();
                sp.SetValue(":t.storage_count!", 0);
                DataTable dtInputStorage = getData.GetTableBySqlStr(Constants.SqlStr.tc_storage_count_yh, sp);

                if (dtInputStorage == null)
                {
                    MessageBox.Show("请查看数据库是否正常!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (dtInputStorage.Rows.Count > 0)
                {
                    dtInputStorage.Columns.Add("index", typeof(int));
                    for (int i = 0; i < dtInputStorage.Rows.Count; i++)
                    {
                        dtInputStorage.Rows[i]["index"] = i + 1;
                    }

                    dgvInputStorage.DataSource = dtInputStorage;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dataAcess.Close();
            }
        }
Beispiel #30
0
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:李梓楠      2010/7/22 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BandingDgv()
        {
            try
            {
                dataAccess = new DataAccess();
                dataAccess.Open();

                GetData         getData = new GetData(dataAccess.Connection);
                SearchParameter sp      = new SearchParameter();
                sp.SetValue(":maintain_code", p_maintain_code);

                DataTable dtCounter = getData.GetSingleTableByCondition("tc_maintain_detail", sp);
                dtCounter.Columns.Add("index", typeof(int));
                for (int i = 0; i < dtCounter.Rows.Count; i++)
                {
                    dtCounter.Rows[i]["index"] = i + 1;
                }
                dgv.DataSource = dtCounter;

                //使被修改对线变为选中行
                if (dgv != null && dgv.Rows.Count > 0 && countNum != 0)
                {
                    dgv.Rows[0].Selected                = false;
                    dgv.Rows[countNum].Selected         = true;
                    dgv.FirstDisplayedScrollingRowIndex = countNum;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw ex;
            }
            finally
            {
                dataAccess.Close();
            }
        }