示例#1
0
        //private void aButton1_Click(object sender, EventArgs e)
        //{
        //    if (openFileDialog1.ShowDialog() == DialogResult.OK)
        //    {
        //        Application.DoEvents();
        //        textBoxFile.Text = openFileDialog1.FileName;
        //        textBoxFile.SelectionStart = textBoxFile.Text.Length;

        //        ds = GetDataSet(textBoxFile.Text, MapLanguageManage.GetStringByMapLanguageConfig(MapLanguageConfig.Map_AwardUserSheetName), "1=1");
        //        if (ds != null)
        //        {
        //            DGVGameUser.AutoGenerateColumns = false;
        //            DGVGameUser.DataSource = ds.Tables[0];
        //            labelUserCount.Text = "(" + ds.Tables[0].Rows.Count.ToString() + ")";
        //        }
        //        else
        //        {
        //            DGVGameUser.Rows.Clear();
        //            labelUserCount.Text = "(0)";
        //        }

        //    }
        //}


        public DataSet GetDataSet(string filename, string tname, string wherestr)//返回excel中不把第一行当做标题看待的数据集
        {
            try
            {
                //OleDbDataAdapter read column donot support ko-kr ,first read the sheet
                string sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename + ";Extended Properties=\"Excel 12.0 Xml;HDR=yes\"";
                System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection(sConnectionString);
                string sql_select_commands = "Select * from [" + tname + "$] where len([" + MapLanguageManage.GetStringByMapLanguageConfig(MapLanguageConfig.Map_UserNo)
                                             + "])>0 and len([" + MapLanguageManage.GetStringByMapLanguageConfig(MapLanguageConfig.Map_RoleNo)
                                             + "])>0 and len([" + MapLanguageManage.GetStringByMapLanguageConfig(MapLanguageConfig.Map_ZoneNo) + "])>0";
                if (wherestr.Length != 0 && wherestr != "1=1")
                {
                    sql_select_commands += " where " + wherestr;
                }
                System.Data.OleDb.OleDbDataAdapter adp = new System.Data.OleDb.OleDbDataAdapter(sql_select_commands, connection);
                DataSet ds = new DataSet();
                adp.Fill(ds, "table_a");
                adp.Dispose();
                connection.Close();
                return(ds);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message.ToString()); return(null);
            }
        }
示例#2
0
        private void SelectFileComplate(object data)
        {
            string path = data as string;

            gridReceiveRole.Columns.Clear();
            if (string.IsNullOrEmpty(path))
            {
                MsgBox.Show(LanguageResource.Language.Tip_PleaseSelectDataFile, LanguageResource.Language.Tip_Tip, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            txtFile.Text = path;
            StringBuilder error = new StringBuilder();
            //加载文件中的数据
            DataSet ds  = OledbFile.GetDataSet(path, SystemConfig.DefaultSheetName, "len([" + MapLanguageManage.GetStringByMapLanguageConfig(MapLanguageConfig.Map_RoleNo) + "])>0", error);
            string  msg = error.ToString();

            if (!string.IsNullOrEmpty(msg))
            {
                MsgBox.Show(msg, LanguageResource.Language.Tip_Tip, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //剔除多余列
            rolesTable = ds.Tables[0].Copy();//是否含有指定的列数据
            int ci = 0;

            DataColumn[] origin = new DataColumn[rolesTable.Columns.Count];
            rolesTable.Columns.CopyTo(origin, 0);
            foreach (DataColumn item in origin)
            {
                string name = item.ColumnName;
                if (excelColumns.Contains(name.Trim()))
                {
                    ci++;
                }
                else
                {
                    rolesTable.Columns.Remove(item);//不能直接使用datatable进行遍历移除【 集合已修改;可能无法执行枚举操作】
                }
            }
            if (ci < excelColumns.Length)
            {
                MsgBox.Show(LanguageResource.Language.Tip_ExcelTemplateError, LanguageResource.Language.Tip_Tip, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            gridReceiveRole.DataSource = rolesTable;
        }
示例#3
0
        void InitLanguageText()
        {
            string[] awardUserGridColumn = SystemConfig.GetAwardUserColumn;
            //DGVGameUser.Columns.Clear();
            List <DataGridViewColumn> columns = new List <DataGridViewColumn>();

            foreach (var item in awardUserGridColumn)
            {
                DataGridViewTextBoxColumn column = new System.Windows.Forms.DataGridViewTextBoxColumn();
                column.AutoSizeMode     = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
                column.DataPropertyName = MapLanguageManage.GetString(item);
                column.FillWeight       = 80F;
                column.HeaderText       = MapLanguageManage.GetString(item);
                column.MinimumWidth     = 84;
                column.Name             = "Column1";
                column.ReadOnly         = true;
                columns.Add(column);
            }
            //DGVGameUser.Columns.AddRange(columns.ToArray());
            this.button7.Text = global::GSSClient.LanguageResource.Language.BtnResetAntiIndulgence;
            this.button6.Text = global::GSSClient.LanguageResource.Language.LblPlayNOTool;
            this.button5.Text = global::GSSClient.LanguageResource.Language.BtnGagTool;
            this.button4.Text = global::GSSClient.LanguageResource.Language.BtnCloseDownRole;
            this.button3.Text = global::GSSClient.LanguageResource.Language.BtnCloseDownAccount;
            label12.Text      = LanguageResource.Language.Tip_AwardUserListExcel;
            label9.Text       = LanguageResource.Language.LblTel;
            this.label3.Text  = LanguageResource.Language.LblVipLevel + "";
            this.label2.Text  = LanguageResource.Language.LblWorkOrderLimit;
            this.label1.Text  = LanguageResource.Language.LblUserList + ":";
            //this.aButton1.Text = LanguageResource.Language.BtnSelectUserListWithImport;
            this.label15.Text              = LanguageResource.Language.LblEmailInfo;
            this.groupBoxInfo.Text         = LanguageResource.Language.LblBaseInfo;
            this.lblURinfo.Text            = LanguageResource.Language.LblBaseInfo;
            this.label8.Text               = LanguageResource.Language.LblInitiatorName;
            this.radioButtonGiftType1.Text = LanguageResource.Language.LblPackage;
            this.radioButtonGiftType0.Text = LanguageResource.Language.LblProp;
            this.label7.Text               = LanguageResource.Language.LblGiftType + ":";
            this.label6.Text               = LanguageResource.Language.LblGiftName + ":";
            this.label7.Text               = LanguageResource.Language.LblGiftType + ":";
            this.label13.Text              = LanguageResource.Language.LblAwardBigZone + ":";
            this.groupBox1.Text            = LanguageResource.Language.LblNoticeList;
            //this.label14.Text = LanguageResource.Language.LblImportUserList + ":";
            btnDosure.Text = LanguageResource.Language.BtnSure;
            btnDoesc.Text  = LanguageResource.Language.BtnCancel;
            this.toolStripStatusLabel1.Text = LanguageResource.Language.LblReady;
            //this.labelUserCount.Text = LanguageResource.Language.LblUnit_Number;
            //邮件标题
            label5.Text = LanguageItems.BaseLanguageItem.LblTitle;

            lbItem1.Text        = LanguageItems.BaseLanguageItem.Lbl_AwardProp1;
            lbItem2.Text        = LanguageItems.BaseLanguageItem.Lbl_AwardProp2;
            lbItem3.Text        = LanguageItems.BaseLanguageItem.Lbl_AwardProp3;
            lbItem4.Text        = LanguageItems.BaseLanguageItem.Lbl_AwardProp4;
            lbItem5.Text        = LanguageItems.BaseLanguageItem.Lbl_AwardProp5;
            lbItemNum1.Text     = LanguageItems.BaseLanguageItem.Lbl_AwardPropNum1;
            lbItemNum2.Text     = LanguageItems.BaseLanguageItem.Lbl_AwardPropNum2;
            lbItemNum3.Text     = LanguageItems.BaseLanguageItem.Lbl_AwardPropNum3;
            lbItemNum4.Text     = LanguageItems.BaseLanguageItem.Lbl_AwardPropNum4;
            lbItemNum5.Text     = LanguageItems.BaseLanguageItem.Lbl_AwardPropNum5;
            lblBlueDiamond.Text = LanguageItems.BaseLanguageItem.LblBlueDiamond;
            lblMoney.Text       = LanguageItems.BaseLanguageItem.LblRedDiamond;
        }