Example #1
0
 private void toolStripButton2_Click(object sender, EventArgs e)
 {
     var sl = new AccountSelectForm(new SysConfigManager().Get().Accounts);
     if (sl.ShowDialog() == DialogResult.OK && sl.CheckedInfo != null)
     {
         _from = sl.CheckedInfo;
         var partner = textBox1.Text;
         var sd = dateTimePicker1.Value.ToString("yyyy-MM-dd 00:00:00");
         var ed = dateTimePicker2.Value.ToString("yyyy-MM-dd 23:59:59");
         var data = new DataAccess(new SqlHelper(_from.GetConnectionString())).GetPurchaseOrder(partner, sd, ed);
         dataGridView1.Columns.Clear();
         dataGridView1.Columns.Add(new DataGridViewCheckBoxColumn { ReadOnly = false, Width = 30 });
         foreach (DataColumn cln in data.Columns)
         {
             dataGridView1.Columns.Add(new DataGridViewTextBoxColumn { Name = cln.ColumnName, ReadOnly = true });
         }
         dataGridView1.Columns[1].Visible = false;
         foreach (DataRow row in data.Rows)
         {
             dataGridView1.Rows.Add(
                 false,
                 row["id"],
                 row["单据日期"],
                 row["单据编号"],
                 row["供应商"],
                 row["业务员"],
                 row["预计到货日期"],
                 row["付款方式"],
                 row["订金金额"],
                 row["预付款百分比"]
             );
         }
         textBox1.Focus();
     }
 }
Example #2
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if (_from == null)
            {
                MessageBox.Show("请先选择导入采购订单");
                return;
            }
            var sl = new AccountSelectForm(new SysConfigManager().Get().Accounts);
            if (sl.ShowDialog() != DialogResult.OK) return;

            var fromSqlHelper = new SqlHelper(_from.GetConnectionString());
            var toSqlHelper = new SqlHelper(sl.CheckedInfo.GetConnectionString());
            var da = new DataAccess(fromSqlHelper);
            var result = new List<string>();
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (!(bool)row.Cells[0].Value) continue;
                var purchaseOrder = da.ImportPurchaseOrder((Guid)row.Cells[1].Value);
                if (purchaseOrder != null && purchaseOrder.Rows.Count > 0)
                {
                    var saleOrder = DataAccess.PurchaseOrderToSaleOrder(purchaseOrder, _from.Name);
                    var rt = new DataAccess(toSqlHelper).ExportSaleOrder(saleOrder);
                    result.AddRange(rt);
                }
            }
            if (result.Count > 0)
            {
                result.Insert(0, "导出成功!\r\n");
                MessageBox.Show(string.Join("\r\n", result));
            }
            else
            {
                MessageBox.Show("没有可导入的采购订单");
            }
        }