Example #1
0
        private void btnSubmit_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.cmbRegion.SelectedValue != null)
                {
                    if (this.cmbRegion.SelectedValue.ToString().Trim() == "")
                    {
                        MessageBox.Show("地区不能为空!");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("地区不能为空!");
                    return;
                }
                GetValues();

                int id = SubscribeInfoManager.CreateSubscribeInfo(name, post, company, address, region, postcode, telephone,
                                                                  mobilePhone, startDate, endDate, giveDate, number, monthCount, totalMoney, inscribe, source, payment, invoice, client, operator1, bonus,
                                                                  localAddress, subscription);
                if (id == 1)                  //添加成功
                {
                    MainForm.Form.CurrentDataSet = SubscribeInfoManager.RetriveDataFromTempInfo();

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else                  //添加失败
                {
                    MessageBox.Show("已经存在该记录!");
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }
        }
Example #2
0
        void ImportDataToDatabase(DataTable sourceTable)
        {
            SubscribeInfoManager.ClearTempInfo();

            foreach (DataRow row in sourceTable.Rows)
            {
                DateTime startDate = DateTime.Parse("1900-1-1");
                DateTime endDate   = DateTime.Parse("1900-1-1");
                DateTime giveDate  = DateTime.Parse("1900-1-1");

                int    number     = -1;
                int    monthCount = -1;
                int    totalMoney = -1;
                string name;
                string localAddress;
                string company;
                string subscription;
                string post;
                string region;
                string address;
                string postcode;
                string mobilePhone;
                string telephone;
                string inscribe;
                string source;
                string payment;
                string invoice;
                string client;
                string operator1;
                string bonus;

                if (row["起始日期"] != DBNull.Value)
                {
                    startDate = DateTime.Parse(row["起始日期"].ToString().Trim());                    //注意:这里一定能够转换,因为如果格式不正确则它的值必定为DBNull.Value
                }
                if (row["结束日期"] != DBNull.Value)
                {
                    endDate = DateTime.Parse(row["结束日期"].ToString().Trim());                    //同上
                }
                if (row["付款日期"] != DBNull.Value)
                {
                    giveDate = DateTime.Parse(row["付款日期"].ToString().Trim());                    //同上
                }
                if (row["份数"] != DBNull.Value)
                {
                    number = Int32.Parse(row["份数"].ToString());                    //同上
                }
                if (row["期数"] != DBNull.Value)
                {
                    monthCount = Int32.Parse(row["期数"].ToString());                    //同上
                }
                if (row["金额"] != DBNull.Value)
                {
                    totalMoney = Int32.Parse(row["金额"].ToString());                    //同上
                }

                name         = row["姓名"].ToString().Trim() == String.Empty ? "  " : row["姓名"].ToString().Trim();
                localAddress = row["县级地区"].ToString().Trim() == String.Empty ? "  " : row["县级地区"].ToString().Trim();
                region       = row["地区"].ToString().Trim() == String.Empty ? "  " : row["地区"].ToString().Trim();
                company      = row["公司"].ToString().Trim() == String.Empty ? "  " : row["公司"].ToString().Trim();
                subscription = row["订阅形式"].ToString().Trim() == String.Empty ? "  " : row["订阅形式"].ToString().Trim();
                post         = row["职位"].ToString().Trim() == String.Empty ? "  " : row["职位"].ToString().Trim();
                address      = row["地址"].ToString().Trim() == String.Empty ? "  " : row["地址"].ToString().Trim();
                postcode     = row["邮编"].ToString().Trim() == String.Empty ? "  " : row["邮编"].ToString().Trim();
                mobilePhone  = row["手机"].ToString().Trim() == String.Empty ? "  " : row["手机"].ToString().Trim();
                telephone    = row["电话"].ToString().Trim() == String.Empty ? "  " : row["电话"].ToString().Trim();
                inscribe     = row["落款"].ToString().Trim() == String.Empty ? "  " : row["落款"].ToString().Trim();
                source       = row["来源"].ToString().Trim() == String.Empty ? "  " : row["来源"].ToString().Trim();
                payment      = row["支付方式"].ToString().Trim() == String.Empty ? "  " : row["支付方式"].ToString().Trim();
                invoice      = row["发票号"].ToString().Trim() == String.Empty ? "  " : row["发票号"].ToString().Trim();
                client       = row["客户类别"].ToString().Trim() == String.Empty ? "  " : row["客户类别"].ToString().Trim();
                operator1    = row["业务员"].ToString().Trim() == String.Empty ? "  " : row["业务员"].ToString().Trim();
                bonus        = row["奖金提取"].ToString().Trim() == String.Empty ? "  " : row["奖金提取"].ToString().Trim();

                SubscribeInfoManager.CreateSubscribeInfo(name, post, company, address, region, postcode, telephone, mobilePhone, startDate, endDate, giveDate, number, monthCount, totalMoney, inscribe, source, payment, invoice, client, operator1, bonus, localAddress, subscription);
            }
        }