Exemple #1
0
        /// <summary>
        /// 原始数据放入数据库,返回批次ID,由报表窗口调用
        /// </summary>
        /// <returns></returns>
        public int WriteToDB()
        {
            //create BathNUM first
            BATCH_INFO bi = new BATCH_INFO
            {
                BI_IMPORTTIME = DateTime.Now,
                BI_ISDEL      = false,
                BI_TIID       = this.TIID,
                BI_UIID       = SysUtil.CurrentUserID(),
            };

            db.BATCH_INFOs.InsertOnSubmit(bi);
            db.SubmitChanges();

            for (int i = 0; i < dgvSals.SelectedRows.Count; i++)
            {
                TEMPLATE_INFO ti    = db.TEMPLATE_INFOs.SingleOrDefault(a => a.TI_ID == this.TIID);
                string        cols  = string.Format("SI_BIID,{0}", ti.TI_COLSINORDER);
                var           value = new List <string>();
                value.Add(bi.BI_ID.ToString());
                for (int index = 0; index < ti.TI_COLSCOUNT; index++)
                {
                    value.Add("'" + dgvSals.SelectedRows[i].Cells[index + 9].Value.ToString() + "'");
                }

                ColumnsDAL cd = new ColumnsDAL();

                cd.OpenConnection(System.Configuration.ConfigurationManager.ConnectionStrings["TaxDemo.Properties.Settings.testdbConnectionString"].ConnectionString);
                cd.WriteRawData(value, cols);
                cd.CloseConnection();
            }

            return(bi.BI_ID);
        }
Exemple #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!checkInput())
            {
                MessageBox.Show("请检查输入项", this.funName, MessageBoxButtons.OK);
                return;
            }

            COLUMNS_INFO ci = new COLUMNS_INFO
            {
                CI_COLNAME = txtColName.Text.Trim().Replace(" ", string.Empty),
                CI_ISVALID = true,
                CI_MARK    = txtMark.Text.Trim(),
                CI_TYPEID  = (short)cbxType.SelectedIndex,
                CI_NAME    = txtName.Text.Trim().Replace(" ", string.Empty),
            };

            db.COLUMNS_INFOs.InsertOnSubmit(ci);
            db.SubmitChanges();

            ColumnsDAL cd = new ColumnsDAL();

            cd.OpenConnection(System.Configuration.ConfigurationManager.ConnectionStrings["TaxDemo.Properties.Settings.testdbConnectionString"].ConnectionString);

            cd.InsertCol(ci);
            cd.CloseConnection();

            MessageBox.Show("添加成功", this.funName, MessageBoxButtons.OK);
            loadCols();
        }