Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string command = string.Empty;

            command = "update \"Authorization\" set \"AuthorizationUser\"='" + this.txtDeal.Text + "' where \"FunctionName\"='ExpressDeal'";
            conn.ExecuteSql(command);
            command = "update \"Authorization\" set \"AuthorizationUser\"='" + this.txtFinish.Text + "' where \"FunctionName\"='ExpressFinish'";
            conn.ExecuteSql(command);
            MessageBox.Show("保存成功!");
        }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            List <string>   selectItem   = new List <string>();
            List <CheckBox> checkBoxList = new List <CheckBox>();

            foreach (Control c in Controls)
            {
                if (c is CheckBox)
                {
                    if (((CheckBox)c).Checked == true)
                    {
                        //selectItem.Add(c.Text);
                        checkBoxList.Add((CheckBox)c);
                    }
                }
            }
            if (checkBoxList.Count() > 0)
            {
                checkBoxList = checkBoxList.OrderBy(v => v.TabIndex).ToList();
                foreach (var checkbox in checkBoxList)
                {
                    selectItem.Add(checkbox.Text);
                }
            }
            if (selectItem.Count() > 0)
            {
                string command = string.Empty;
                command = "select * from \"Authorization\" where FunctionName='RepeatTipItem' ";
                DataTable dt    = conn.GetDataTableBySql(command);
                string    item  = string.Join(",", selectItem);
                string    error = string.Empty;
                if (dt.Rows.Count == 0)
                {
                    command = "insert into \"Authorization\"(FunctionName,AuthorizationUser) values('RepeatTipItem','" + item + "')";
                    error   = conn.ExecuteSql(command);
                }
                else
                {
                    command = "update \"Authorization\" set AuthorizationUser='******' where FunctionName='RepeatTipItem'";
                    error   = conn.ExecuteSql(command);
                }
                if (!string.IsNullOrWhiteSpace(error))
                {
                    MessageBox.Show("保存失败,失败原因:" + error);
                }
                else
                {
                    MessageBox.Show("保存成功!");
                    this.Hide();
                }
            }
        }
Exemple #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(this.txtInput.Text))
     {
         if (Directory.Exists(this.txtInput.Text) == true)
         {
             string command = string.Empty;
             command = "update \"Value\" set \"value\"='" + this.txtInput.Text + "' where \"id\"='999'";
             string message = sqlConn.ExecuteSql(command);
             if (!string.IsNullOrWhiteSpace(message))
             {
                 MessageBox.Show("操作失败,失败原因:" + message);
             }
             else
             {
                 this.PicPath = this.txtInput.Text;
                 IsUpdate     = true;
                 MessageBox.Show("保存成功");
                 this.Close();
             }
         }
         else
         {
             MessageBox.Show("输入的路径不存在,请检查!");
         }
     }
 }
Exemple #4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         string command = string.Empty;
         //先删除所有数据
         command = "delete from ResionSet";
         conn.ExecuteSql(command);
         foreach (var item in this.ResionList)
         {
             if (item.Days > 0)
             {
                 command = " insert into ResionSet(Resion,Days) values('" + item.Resion + "'," + item.Days + ")";
                 conn.ExecuteSql(command);
             }
         }
         MessageBox.Show("保存成功");
     }
     catch (Exception ex)
     {
         MessageBox.Show("保存失败,原因:" + ex.Message);
     }
 }
Exemple #5
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         string command = string.Empty;
         //先删除所有数据
         command = "delete from CompanySet";
         conn.ExecuteSql(command);
         foreach (var item in this.CompanyList)
         {
             if (!string.IsNullOrWhiteSpace(item.CompanyName) && !string.IsNullOrWhiteSpace(item.ExpressNo))
             {
                 command = " insert into CompanySet(CompanyName,ExpressNo) values('" + item.CompanyName + "'," + item.ExpressNo + ")";
                 conn.ExecuteSql(command);
             }
         }
         MessageBox.Show("保存成功");
     }
     catch (Exception ex)
     {
         MessageBox.Show("保存失败,原因:" + ex.Message);
     }
 }
Exemple #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.cmbAilpayNo.SelectedItem.ToString()))
     {
         string command = string.Empty;
         command = "update \"Value\" set money='" + this.textBox1.Text + "' where \"value\"='" + this.cmbAilpayNo.SelectedItem.ToString() + "'";
         string message = conn.ExecuteSql(command);
         if (!string.IsNullOrWhiteSpace(message))
         {
             MessageBox.Show("保存失败:" + message);
         }
         else
         {
             MessageBox.Show("保存成功");
         }
     }
 }
Exemple #7
0
        private void RegisterUser(string userName, string password, string name)
        {
            string command = string.Empty;

            command = "select * from \"User\" where \"UserName\"='" + userName + "'";
            DataTable tb  = sqlConn.GetDataTableBySql(command);
            string    sql = string.Empty;

            sql = " select * from \"User\" where \"Name\"='" + name + "'";
            DataTable tName = sqlConn.GetDataTableBySql(sql);

            if (tb.Rows.Count > 0)
            {
                MessageBox.Show("用户名已经被注册");
                return;
            }
            else if (tName.Rows.Count > 0)
            {
                MessageBox.Show("姓名已经被注册");
                return;
            }
            else
            {
                command = "insert into \"User\"(\"UserName\",\"Password\",\"Name\",\"IsDelete\") values('" + userName + "','" + password + "','" + name + "',1)";
                string message = sqlConn.ExecuteSql(command);
                if (string.IsNullOrWhiteSpace(message))
                {
                    MessageBox.Show("注册成功");
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("注册失败,失败原因:" + message);
                }
            }
        }
Exemple #8
0
        private void button2_Click(object sender, EventArgs e)
        {
            string command = string.Empty;

            if (string.IsNullOrWhiteSpace(this.txtExpressNo.Text))
            {
                MessageBox.Show("请输入快递单号!");
                return;
            }
            if (string.IsNullOrWhiteSpace(this.txtExpressCompany.Text))
            {
                MessageBox.Show("请输入快递公司!");
                return;
            }
            if (string.IsNullOrWhiteSpace(this.cmbResion.Text))
            {
                MessageBox.Show("请输入原因!");
                return;
            }
            command = " insert into ExpressReceive(ExpressNo,ExpressCompany,Resion,Status,CreateUser,BuyAdress,IsDelete) values('" + this.txtExpressNo.Text + "','" + this.txtExpressCompany.Text + "','" + this.cmbResion.Text + "','未处理','" + this.txtCreateUser.Text + "','" + this.txtBuyAdress.Text + "','False') ";
            string message = conn.ExecuteSql(command);

            if (!string.IsNullOrWhiteSpace(message))
            {
                MessageBox.Show("保存失败!失败原因:" + message);
            }
            else
            {
                MessageBox.Show("录入成功");
                this.txtExpressNo.Text      = "";
                this.txtExpressCompany.Text = "";
                this.txtBuyAdress.Text      = "";
                this.cmbResion.Text         = "";
                this.isAutoRe = false;
            }
        }
Exemple #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "日志文件 (*.xls)|*.xls;*.xlsx";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex      = 1;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string strCon = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + openFileDialog.FileName + ";Extended Properties='Excel 12.0; HDR=NO; IMEX=1'";
                System.Data.OleDb.OleDbConnection myConn = new System.Data.OleDb.OleDbConnection(strCon);
                string strCom = " SELECT * FROM [Sheet1$] ";
                System.Data.OleDb.OleDbDataAdapter myCommand = new System.Data.OleDb.OleDbDataAdapter(strCom, myConn);
                System.Data.DataTable dt = new System.Data.DataTable();
                myCommand.Fill(dt);
                int seqNum = 1;
                allExpressNo = new List <string>();
                for (int i = 1; i < dt.Rows.Count; i++)
                {
                    allExpressNo.Add(dt.Rows[i][3].ToString());
                }

                if (allExpressNo.Count() > 0)
                {
                    int           allApplyCount  = 2900;
                    int           take           = 0;
                    string        command        = string.Empty;
                    int           needApplyCount = allExpressNo.Count();
                    List <string> applyExpress   = new List <string>();
                    List <int>    searchSeq      = new List <int>();
                    hasExpress   = new List <ExpressEntry>();
                    noHasExpress = new List <ExpressEntry>();
                    failExpress  = new List <ExpressEntry>();
                    hasSeq       = 1;
                    noHasSeqNo   = 1;
                    failSeqNo    = 1;
                    while (needApplyCount > 0)
                    {
                        Random rd  = new Random();
                        int    seq = rd.Next(1, 6);
                        while (searchSeq.Where(v => v == seq).Count() > 0)
                        {
                            seq = rd.Next(1, 6);
                        }

                        //查询使用的帐号
                        command = "select * from Accounts where seqNum=" + seq + "";
                        dt      = conn.GetDataTableBySql(command);
                        if (dt.Rows.Count > 0)
                        {
                            var busID           = dt.Rows[0]["businessID"].ToString();
                            var appKey          = dt.Rows[0]["appkey"].ToString();
                            int todayApplyCount = 0;
                            if (!string.IsNullOrWhiteSpace(busID))
                            {
                                //查询该帐号当天申请次数
                                command = "select * from ApplyRecord where businessID=" + busID + " and Datename(year,applDate)+'-'+Datename(month,applDate)+'-'+Datename(day,applDate)='" + DateTime.Today.ToString("yyyy-MM-dd") + "'";
                                int?id = null;
                                dt = conn.GetDataTableBySql(command);
                                if (dt.Rows.Count > 0)
                                {
                                    todayApplyCount = int.Parse(dt.Rows[0]["applyCount"].ToString());
                                    id = int.Parse(dt.Rows[0]["id"].ToString());
                                }
                                //剩余查询总数量
                                int surplusCount = allApplyCount - todayApplyCount;
                                if (surplusCount > 0)
                                {
                                    //当前需要查询且可查询的数量
                                    int vail = surplusCount - needApplyCount;
                                    //查询数量
                                    int thisTimeCount = 0;
                                    if (vail < 0)
                                    {
                                        thisTimeCount = surplusCount;
                                        //当天已经用满的帐号不再使用
                                        searchSeq.Add(seq);
                                    }
                                    else
                                    {
                                        thisTimeCount = needApplyCount;
                                    }
                                    //跳过已查询的的
                                    applyExpress = allExpressNo.Skip(take).Take(thisTimeCount).ToList();
                                    //记录已查询数
                                    take = thisTimeCount;
                                    //减去已查询的数
                                    needApplyCount = needApplyCount - take;

                                    int needUpdateCount = todayApplyCount + take;
                                    //更新数据库已查询的数
                                    if (id.HasValue)
                                    {
                                        command = "update ApplyRecord set applyCount=" + needUpdateCount + " where id=" + id + "";
                                        conn.ExecuteSql(command);
                                    }
                                    else
                                    {
                                        command = "insert into ApplyRecord(businessID,applyCount) values('" + busID + "'," + needUpdateCount + ")";
                                        conn.ExecuteSql(command);
                                    }
                                    this.BusinessID = busID;
                                    this.AppKey     = appKey;
                                    DealExpressNo(applyExpress);
                                }
                            }
                        }
                    }
                    this.dataGridView1.DataSource = null;
                    this.dataGridView2.DataSource = null;
                    this.dataGridView3.DataSource = null;
                    this.dataGridView1.DataSource = this.hasExpress;
                    this.dataGridView2.DataSource = this.noHasExpress;
                    this.dataGridView3.DataSource = this.failExpress;
                }
            }
        }
Exemple #10
0
        private void Search()
        {
            ResultList = new List <ExpressReceiveEntry>();
            string command = string.Empty;

            command = "select * from ExpressReceive where IsDelete =0 ";
            if (!string.IsNullOrWhiteSpace(this.txtExpressNo.Text))
            {
                command += " and ExpressNo like '%" + this.txtExpressNo.Text + "%'";
            }
            if (!string.IsNullOrWhiteSpace(this.txtCompanyName.Text))
            {
                command += " and ExpressCompany like '%" + this.txtCompanyName.Text + "%'";
            }
            if (!string.IsNullOrWhiteSpace(this.cmbResion.Text))
            {
                command += " and Resion like '%" + this.cmbResion.Text + "%'";
            }
            if (!string.IsNullOrWhiteSpace(this.cmbStatus.Text))
            {
                command += " and Status like '%" + this.cmbStatus.Text + "%'";
            }
            if (!string.IsNullOrWhiteSpace(this.cmbResult.Text))
            {
                command += " and Result like '%" + this.cmbResult.Text + "%'";
            }
            if (!string.IsNullOrWhiteSpace(this.txtCreateUser.Text))
            {
                command += " and CreateUser like '%" + this.txtCreateUser.Text + "%'";
            }
            if (this.timePickFrom.Value != null)
            {
                var timeFrom = this.timePickFrom.Value;
                timeFrom = timeFrom.AddHours(-this.timePickFrom.Value.Hour).AddMinutes(-this.timePickFrom.Value.Minute).AddSeconds(-this.timePickFrom.Value.Second);
                //DealTime //FinishTime
                if (this.cmbTime.Text == "录入时间")
                {
                    command += " and convert(datetime,CreateTime) >='" + timeFrom.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                }
                else if (this.cmbTime.Text == "处理时间")
                {
                    command += " and convert(datetime,DealTime) >='" + timeFrom.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                }
                else if (this.cmbTime.Text == "完结时间")
                {
                    command += " and convert(datetime,FinishTime) >='" + timeFrom.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                }
            }
            if (this.timePickTo.Value != null)
            {
                var timeTo = this.timePickTo.Value;
                timeTo = timeTo.AddHours(-this.timePickTo.Value.Hour).AddMinutes(-this.timePickTo.Value.Minute).AddSeconds(-this.timePickTo.Value.Second);
                timeTo = timeTo.AddHours(23).AddMinutes(59).AddSeconds(59);

                if (this.cmbTime.Text == "录入时间")
                {
                    command += " and convert(datetime,CreateTime) <='" + timeTo.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                }
                else if (this.cmbTime.Text == "处理时间")
                {
                    command += " and convert(datetime,DealTime) <='" + timeTo.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                }
                else if (this.cmbTime.Text == "完结时间")
                {
                    command += " and convert(datetime,FinishTime) <='" + timeTo.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                }
                //command += " and convert(datetime,CreateTime) <='" + timeTo.ToString("yyyy-MM-dd HH:mm:ss") + "'";
            }
            DataTable dt = conn.GetDataTableBySql(command);

            if (dt.Rows.Count > 0)
            {
                int seq = 1;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ExpressReceiveEntry entry = new ExpressReceiveEntry();
                    entry.SeqNum         = seq;
                    entry.ID             = int.Parse(dt.Rows[i]["ID"].ToString());
                    entry.Status         = dt.Rows[i]["Status"].ToString();
                    entry.ExpressNo      = dt.Rows[i]["ExpressNo"].ToString();
                    entry.ExpressCompany = dt.Rows[i]["ExpressCompany"].ToString();
                    entry.BuyAdress      = dt.Rows[i]["BuyAdress"].ToString();
                    entry.Resion         = dt.Rows[i]["Resion"].ToString();
                    entry.CreateUser     = dt.Rows[i]["CreateUser"].ToString();
                    entry.DealUser       = dt.Rows[i]["DealUser"].ToString();
                    entry.Remark         = dt.Rows[i]["Remark"].ToString();
                    entry.Remark2        = dt.Rows[i]["Remark2"].ToString();
                    entry.Remark3        = dt.Rows[i]["Remark3"].ToString();
                    entry.Remark4        = dt.Rows[i]["Remark4"].ToString();
                    entry.Result         = dt.Rows[i]["Result"].ToString();
                    if (!string.IsNullOrEmpty(dt.Rows[i]["DealTime"].ToString()))
                    {
                        entry.DealTime = DateTime.Parse(dt.Rows[i]["DealTime"].ToString());
                    }
                    if (!string.IsNullOrEmpty(dt.Rows[i]["CreateTime"].ToString()))
                    {
                        entry.CreateTime = DateTime.Parse(dt.Rows[i]["CreateTime"].ToString());
                    }
                    if (!string.IsNullOrEmpty(dt.Rows[i]["FinishTime"].ToString()))
                    {
                        entry.FinishTime = DateTime.Parse(dt.Rows[i]["FinishTime"].ToString());
                    }
                    seq++;
                    ResultList.Add(entry);
                }
                //处理已超时
                command = "select * from ResionSet";
                dt      = conn.GetDataTableBySql(command);
                if (dt.Rows.Count > 0)
                {
                    List <ResionEntry> resionList = new List <ResionEntry>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ResionEntry entry = new ResionEntry();
                        entry.Days   = int.Parse(dt.Rows[i]["Days"].ToString());
                        entry.Resion = dt.Rows[i]["Resion"].ToString();
                        resionList.Add(entry);
                    }
                    foreach (var item in ResultList.Where(v => v.Status == "已处理" || v.Status == "未处理").ToList())
                    {
                        var resionEntry = resionList.Where(v => v.Resion == item.Resion).FirstOrDefault();
                        if (resionEntry != null)
                        {
                            var      time      = resionEntry.Days * 24;
                            TimeSpan?totalTime = DateTime.Now - item.CreateTime;
                            if (totalTime.HasValue && totalTime.Value.TotalHours > time)
                            {
                                command = " update ExpressReceive set Status='已超时' where id='" + item.ID + "'";
                                string message = conn.ExecuteSql(command);
                                item.Status = "已超时";
                                //if (!string.IsNullOrWhiteSpace(message))
                                //    MessageBox.Show("序号:" + item.SeqNum + " 处理失败" + "失败原因:" + message);
                            }
                        }
                    }
                }
            }
            this.dgShow.DataSource = null;
            this.dgShow.DataSource = ResultList;
        }
Exemple #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string command = string.Empty;

            //if(!string.IsNullOrWhiteSpace(this.txtInput.Text))
            //{
            command = "update \"Authorization\" set \"AuthorizationUser\"='" + this.txtInput.Text + "' where \"FunctionName\"='Input'";
            conn.ExecuteSql(command);
            //}
            //if (!string.IsNullOrWhiteSpace(this.txtDeal.Text))
            //{
            command = "update \"Authorization\" set \"AuthorizationUser\"='" + this.txtDeal.Text + "' where \"FunctionName\"='Deal'";
            conn.ExecuteSql(command);
            //}
            //if (!string.IsNullOrWhiteSpace(this.txtResion.Text))
            //{
            command = "update \"Authorization\" set \"AuthorizationUser\"='" + this.txtResion.Text + "' where \"FunctionName\"='Resion'";
            conn.ExecuteSql(command);
            //}
            //if (!string.IsNullOrWhiteSpace(this.txtShopName.Text))
            //{
            command = "update \"Authorization\" set \"AuthorizationUser\"='" + this.txtShopName.Text + "' where \"FunctionName\"='ShopName'";
            conn.ExecuteSql(command);
            //}
            //if (!string.IsNullOrWhiteSpace(this.txtDelete.Text))
            //{
            command = "update \"Authorization\" set \"AuthorizationUser\"='" + this.txtDelete.Text + "' where \"FunctionName\"='Delete'";
            conn.ExecuteSql(command);
            //}
            //if (!string.IsNullOrWhiteSpace(this.txtAlipayNo.Text))
            //{
            command = "update \"Authorization\" set \"AuthorizationUser\"='" + this.txtAlipayNo.Text + "' where \"FunctionName\"='AlipayNo'";
            conn.ExecuteSql(command);
            //}
            //if (!string.IsNullOrWhiteSpace(this.txtUpdatePath.Text))
            //{
            command = "update \"Authorization\" set \"AuthorizationUser\"='" + this.txtUpdatePath.Text + "' where \"FunctionName\"='UpdatePathUser'";
            conn.ExecuteSql(command);
            //}
            command = "update \"Authorization\" set \"AuthorizationUser\"='" + this.tbPictureUser.Text + "' where \"FunctionName\"='PictureUser'";
            conn.ExecuteSql(command);
            command = "select * from \"Authorization\" where \"FunctionName\"='AuditUser'";
            DataTable tb = conn.GetDataTableBySql(command);

            if (tb.Rows.Count == 0)
            {
                command = "insert into \"Authorization\"(\"AuthorizationUser\",\"FunctionName\") values('" + this.txtAuditUser.Text + "','AuditUser')";
                conn.ExecuteSql(command);
            }
            else
            {
                command = "update \"Authorization\" set \"AuthorizationUser\"='" + this.txtAuditUser.Text + "' where \"FunctionName\"='AuditUser'";
                conn.ExecuteSql(command);
            }

            var alipayList = this.txtAlipayNo.Text.Split(',').ToList();

            if (alipayList.Count() > 0)
            {
                foreach (var no in alipayList)
                {
                    if (string.IsNullOrWhiteSpace(no))
                    {
                        continue;
                    }
                    command = "select * from Value where value='" + no + "'";
                    tb      = conn.GetDataTableBySql(command);
                    if (tb.Rows.Count == 0)
                    {
                        command = "insert into Value(value,money) values('" + no + "',0)";
                        conn.ExecuteSql(command);
                    }
                }
            }


            MessageBox.Show("保存成功!");
            //Main main = new Main();
            //main.Show();
            this.Hide();
        }
Exemple #12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string command = string.Empty;

            if (isShowTip == false)
            {
                if (!string.IsNullOrWhiteSpace(this.tbBuyerID.Text))
                {
                    command = string.Empty;
                    command = "select * from \"OrderRecord\" where \"BuyersID\" like '%" + this.tbBuyerID.Text.Trim() + "%' and \"IsDelete\"='False' order by convert(datetime,CreateTime) desc";
                    DataTable dt = conn.GetDataTableBySql(command);
                    if (dt.Rows.Count > 0)
                    {
                        DateTime createTime = DateTime.Parse(dt.Rows[0]["CreateTime"].ToString());
                        var      time       = DateTime.Now - createTime;
                        if (time.TotalDays <= 30)
                        {
                            if (MessageBox.Show("    买家ID已存在退款记录,请核对!是否继续保存?", "提醒", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                            }
                            else
                            {
                                return;
                            }
                            //if(MessageBox.Show("买家ID已存在退款记录,请核对!", "提示"));
                            //return;
                        }
                    }
                }
            }

            if (string.IsNullOrWhiteSpace(this.cmbShopName.Text))
            {
                MessageBox.Show("请输入店铺名称!");
                return;
            }
            if (string.IsNullOrWhiteSpace(this.tbBuyerID.Text))
            {
                MessageBox.Show("请输入买家ID!");
                return;
            }
            if (string.IsNullOrWhiteSpace(this.cmbRefundWay.Text))
            {
                MessageBox.Show("请输入退款方式!");
                return;
            }
            if (this.cmbRefundWay.Text == "支付宝")
            {
                if (string.IsNullOrWhiteSpace(this.tbAlipayNo.Text))
                {
                    MessageBox.Show("请输入支付宝帐号!");
                    return;
                }
                else if (this.tbAlipayNo.Text.Length < 5)
                {
                    MessageBox.Show("支付宝账号应大于5个字符");
                    return;
                }
            }



            int id = 0;

            command = "select max(id) from OrderRecord ";
            DataTable dt1 = conn.GetDataTableBySql(command);

            if (dt1.Rows.Count > 0)
            {
                id = int.Parse(dt1.Rows[0][0].ToString());
            }
            id++;

            string  refundResion = string.Empty;
            decimal amount1      = 0;
            decimal refundAmount = 0;

            detailList = new List <RefundDetail>();
            RefundDetail entry = new RefundDetail();

            entry.orderId = id;
            if (!string.IsNullOrWhiteSpace(this.tbRefundAmount.Text))
            {
                entry.RefundAmount = decimal.Parse(this.tbRefundAmount.Text);
            }
            entry.RefundResoin = this.cmbRefundResoin.Text;
            entry.code         = this.txtCode.Text;
            detailList.Add(entry);
            refundAmount += entry.RefundAmount;
            refundResion  = entry.RefundResoin + "     " + entry.RefundAmount + "     " + entry.code + Environment.NewLine;

            #region 退款原因赋值
            if (!string.IsNullOrWhiteSpace(this.tbCode1.Text) || !string.IsNullOrWhiteSpace(this.tbRefundAmount1.Text) || !string.IsNullOrWhiteSpace(this.cmbRefundResoin1.Text))
            {
                RefundDetail entry1 = new RefundDetail();
                entry1.orderId = id;
                if (!string.IsNullOrWhiteSpace(this.tbRefundAmount1.Text))
                {
                    entry1.RefundAmount = decimal.Parse(this.tbRefundAmount1.Text);
                }
                amount1             = entry1.RefundAmount;
                entry1.RefundResoin = this.cmbRefundResoin1.Text;
                entry1.code         = this.tbCode1.Text;
                refundAmount       += entry1.RefundAmount;
                refundResion       += entry1.RefundResoin + "     " + amount1 + "     " + entry1.code + Environment.NewLine;
                detailList.Add(entry1);
            }
            if (!string.IsNullOrWhiteSpace(this.tbCode2.Text) || !string.IsNullOrWhiteSpace(this.tbRefundAmount2.Text) || !string.IsNullOrWhiteSpace(this.cmbRefundResoin2.Text))
            {
                RefundDetail entry1 = new RefundDetail();
                entry1.orderId = id;
                if (!string.IsNullOrWhiteSpace(this.tbRefundAmount2.Text))
                {
                    entry1.RefundAmount = decimal.Parse(this.tbRefundAmount2.Text);
                }
                amount1             = entry1.RefundAmount;
                entry1.RefundResoin = this.cmbRefundResoin2.Text;
                entry1.code         = this.tbCode2.Text;
                refundAmount       += entry1.RefundAmount;
                refundResion       += entry1.RefundResoin + "     " + amount1 + "     " + entry1.code + Environment.NewLine;
                detailList.Add(entry1);
            }
            if (!string.IsNullOrWhiteSpace(this.tbCode3.Text) || !string.IsNullOrWhiteSpace(this.tbRefundAmount3.Text) || !string.IsNullOrWhiteSpace(this.cmbRefundResoin3.Text))
            {
                RefundDetail entry1 = new RefundDetail();
                entry1.orderId = id;
                if (!string.IsNullOrWhiteSpace(this.tbRefundAmount3.Text))
                {
                    entry1.RefundAmount = decimal.Parse(this.tbRefundAmount3.Text);
                }
                amount1             = entry1.RefundAmount;
                entry1.RefundResoin = this.cmbRefundResoin3.Text;
                entry1.code         = this.tbCode3.Text;
                refundAmount       += entry1.RefundAmount;
                refundResion       += entry1.RefundResoin + "     " + amount1 + "     " + entry1.code + Environment.NewLine;
                detailList.Add(entry1);
            }
            if (!string.IsNullOrWhiteSpace(this.tbCode4.Text) || !string.IsNullOrWhiteSpace(this.tbRefundAmount4.Text) || !string.IsNullOrWhiteSpace(this.cmbRefundResoin4.Text))
            {
                RefundDetail entry1 = new RefundDetail();
                entry1.orderId = id;
                if (!string.IsNullOrWhiteSpace(this.tbRefundAmount4.Text))
                {
                    entry1.RefundAmount = decimal.Parse(this.tbRefundAmount4.Text);
                }
                amount1             = entry1.RefundAmount;
                entry1.RefundResoin = this.cmbRefundResoin4.Text;
                entry1.code         = this.tbCode4.Text;
                refundAmount       += entry1.RefundAmount;
                refundResion       += entry1.RefundResoin + "     " + amount1 + "     " + entry1.code + Environment.NewLine;
                detailList.Add(entry1);
            }
            if (!string.IsNullOrWhiteSpace(this.tbCode5.Text) || !string.IsNullOrWhiteSpace(this.tbRefundAmount5.Text) || !string.IsNullOrWhiteSpace(this.cmbRefundResoin5.Text))
            {
                RefundDetail entry1 = new RefundDetail();
                entry1.orderId = id;
                if (!string.IsNullOrWhiteSpace(this.tbRefundAmount5.Text))
                {
                    entry1.RefundAmount = decimal.Parse(this.tbRefundAmount5.Text);
                }
                amount1             = entry1.RefundAmount;
                entry1.RefundResoin = this.cmbRefundResoin5.Text;
                entry1.code         = this.tbCode5.Text;
                refundAmount       += entry1.RefundAmount;
                refundResion       += entry1.RefundResoin + "     " + amount1 + "     " + entry1.code + Environment.NewLine;
                detailList.Add(entry1);
            }
            #endregion
            //if (this.dataGridView1.Rows.Count > 0)
            //{
            //    foreach (var item in this.dataGridView1.Rows)
            //    {
            //        var gridRow = item as DataGridViewRow;
            //        //var row = gridRow.DataBoundItem as RefundDetail;
            //        if (gridRow.Cells[0].Value != null)
            //        {
            //            if (!string.IsNullOrWhiteSpace(gridRow.Cells[0].Value.ToString()))
            //                amount1 = decimal.Parse(gridRow.Cells[0].Value.ToString());
            //            refundAmount += amount1;
            //            refundResion += gridRow.Cells[2].Value + "     " + amount1 + "     " + gridRow.Cells[1].Value + Environment.NewLine;
            //            RefundDetail entry1 = new RefundDetail();
            //            entry1.orderId = id;
            //            entry1.RefundAmount = amount1;
            //            if (gridRow.Cells[2].Value!=null)
            //            entry1.RefundResoin = gridRow.Cells[2].Value.ToString();
            //            if (gridRow.Cells[1].Value != null)
            //                entry1.code = gridRow.Cells[1].Value.ToString();
            //            detailList.Add(entry1);
            //        }
            //    }

            //}
            //else
            //{
            //    refundAmount = decimal.Parse(this.tbRefundAmount.Text);
            //    refundResion = this.cmbRefundResoin.Text;
            //}
            if (string.IsNullOrWhiteSpace(this.tbRefundAmount.Text) && detailList.Where(v => v.RefundAmount > 0).Count() == 0 && this.cmbRefundWay.Text != "补发")
            {
                MessageBox.Show("请输入退款金额!");
                return;
            }
            if (string.IsNullOrWhiteSpace(this.cmbRefundResoin.Text) && detailList.Where(v => !string.IsNullOrWhiteSpace(v.RefundResoin)).Count() == 0)
            {
                MessageBox.Show("请输入退款原因!");
                return;
            }
            //decimal amount = decimal.Parse(decimal.Parse(this.tbRefundAmount.Text).ToString("F2"));
            decimal amount = 0;
            amount = decimal.Parse(refundAmount.ToString("F2"));
            string status = string.Empty;
            if ((this.cmbRefundWay.Text == "支付宝" && amount >= 15) || (this.cmbRefundResoin.Text == "漏发" && amount > 10))
            {
                status = "待审核";
            }
            else
            {
                status = "未处理";
            }

            //处理录入次数
            int inputCount = this.QueryInputCount(this.tbBuyerID.Text);

            command  = "set IDENTITY_INSERT OrderRecord ON ;";
            command += " insert into \"OrderRecord\"(\"id\",\"Status\",\"ShopName\",\"BuyersID\",\"RefundWay\",\"AlipayNo\",\"RefundAmount\",\"RefundResoin\",\"Remark\",\"CreateUser\",\"IsDelete\",\"PDName1\",\"PDName2\",\"PDName3\",\"PDName4\",\"PDName5\",\"ExpressNo2\",\"ExpressNo3\",InputCount) Values(" + id + ",'" + status + "','" + this.cmbShopName.Text + "','" + this.tbBuyerID.Text + "','" + this.cmbRefundWay.Text + "','" + this.tbAlipayNo.Text + "','" + amount + "','" + refundResion + "','" + this.tbRemark.Text + "','" + this.tbCreateUser.Text + "','false','" + this.tbPdName1.Text + "','" + this.tbPdName2.Text + "','" + this.tbPdName3.Text + "','" + this.tbPdName4.Text + "','" + this.tbExpressNo1.Text + "','" + this.tbExpressNo2.Text + "','" + this.tbExpressNo3.Text + "'," + inputCount + ") ;";
            command += "set IDENTITY_INSERT OrderRecord off;";
            string message = conn.ExecuteSql(command);
            if (!string.IsNullOrWhiteSpace(message))
            {
                MessageBox.Show("保存失败!失败原因:" + message);
            }
            else
            {
                MessageBox.Show("录入成功");
                if (detailList.Count() > 0)
                {
                    foreach (var item in detailList)
                    {
                        command = "insert into RefundDetail(orderId,RefundAmount,RefundResoin,code) values('" + item.orderId + "','" + item.RefundAmount + "','" + item.RefundResoin + "','" + item.code + "')";
                        message = conn.ExecuteSql(command);
                    }
                }

                //this.dataGridView1.DataSource = null;
                //foreach (var item in this.dataGridView1.Rows)
                //{
                //    var gridRow = item as DataGridViewRow;
                //    this.dataGridView1.Rows.Remove(gridRow);
                //}
                this.tbBuyerID.Text      = "";
                this.tbAlipayNo.Text     = "";
                this.tbRefundAmount.Text = "";
                //this.cmbRefundWay.Text = "";
                this.cmbRefundResoin.Text = "";
                this.tbCreateUser.Text    = UserEntry.Name;
                this.tbRemark.Text        = "";
                this.tbPdName1.Text       = "";
                this.tbPdName2.Text       = "";
                this.tbPdName3.Text       = "";
                this.tbPdName4.Text       = "";
                this.tbExpressNo1.Text    = "";
                this.tbExpressNo2.Text    = "";
                this.tbExpressNo3.Text    = "";
                this.tbUp.Text            = "";

                this.tbCode1.Text                   = "";
                this.tbCode2.Text                   = "";
                this.tbCode3.Text                   = "";
                this.tbCode4.Text                   = "";
                this.tbCode5.Text                   = "";
                this.tbRefundAmount1.Text           = "";
                this.tbRefundAmount2.Text           = "";
                this.tbRefundAmount3.Text           = "";
                this.tbRefundAmount4.Text           = "";
                this.tbRefundAmount5.Text           = "";
                this.cmbRefundResoin1.SelectedIndex = 0;
                this.cmbRefundResoin2.SelectedIndex = 0;
                this.cmbRefundResoin3.SelectedIndex = 0;
                this.cmbRefundResoin4.SelectedIndex = 0;
                this.cmbRefundResoin5.SelectedIndex = 0;
                //this.dataGridView1.DataSource = null;
                //while (this.dataGridView1.Rows.Count > 0)
                //{
                //    this.dataGridView1.Rows.RemoveAt(0);
                //}
                ////this.dataGridView1.i
                //this.dataGridView1.Rows.Add();
                //this.dataGridView1.Rows.Add();
                //this.dataGridView1.Rows.Add();
                //this.dataGridView1.Rows.Add();
                //this.dataGridView1.Rows.Add();
                //Input input = new Input(shopNameList, refundWay);
                //this.Hide();
                //input.Show();
                //this.Hide();
            }
        }