private async void SaveData() { var r = new Dictionary <string, object>(); r["ci-id"] = m_ciId; r["real-name"] = tbRealName.Text.Trim(); r["mobile"] = tbMobile.Text.Trim(); r["company"] = tbCompany.Text.Trim(); r["position"] = tbPosition.Text.Trim(); r["city"] = tbCity.Text.Trim(); r["birth"] = (DateTime.Now.AddYears(-Convert.ToInt32(nudAge.Value))).TruncToStart(); r["gender"] = cbbGender.GetSelectedValue(); r["origin-type"] = tbSourceType.Text.Trim(); r["pr-level"] = cbbPrLevel.GetSelectedValue(); r["remark"] = tbRemark.Text.Trim().LeftStr(2000); IResult p; if (m_ciId == 0) { p = await CrmInvestor.Create(r); } else { p = await CrmInvestor.Update(r); } if (p.IsOk) { DlgResult = p; DialogResult = DialogResult.OK; } else { Commons.ShowResultErrorBox(this, p); } }
private void btnImport_Click(object sender, EventArgs e) { var dlg = new ImportWizardDlg(new List <Tuple <string, CellType, bool> >() { ImportWizardDlg.MakeColumn("姓名", CellType.Text), ImportWizardDlg.MakeColumn("手机", CellType.Mobile, true), ImportWizardDlg.MakeColumn("工作单位", CellType.Text), ImportWizardDlg.MakeColumn("职务", CellType.Text), ImportWizardDlg.MakeColumn("所在城市", CellType.Text), ImportWizardDlg.MakeColumn("年龄", CellType.Age), ImportWizardDlg.MakeColumn("性别", CellType.Text), ImportWizardDlg.MakeColumn("备注", CellType.Text), ImportWizardDlg.MakeColumn("客户来源", CellType.Text), ImportWizardDlg.MakeColumn("等级", CellType.Text) }); dlg.StartPosition = FormStartPosition.CenterParent; dlg.RunSingle += (index, gridView) => { var r = new Dictionary <string, object>(); r["ci-id"] = 0; r["real-name"] = gridView.Rows[index].Cells[0].Value.TrimStr(); r["mobile"] = gridView.Rows[index].Cells[1].Value.TrimStr(); r["company"] = gridView.Rows[index].Cells[2].Value.TrimStr(); r["position"] = gridView.Rows[index].Cells[3].Value.TrimStr(); r["city"] = gridView.Rows[index].Cells[4].Value.TrimStr(); var ageStr = gridView.Rows[index].Cells[5].Value.TrimStr(); if (ageStr != "") { var age = Convert.ToInt32(ageStr); if (age > 0) { r["birth"] = DateTime.Now.AddYears(-age).TruncToStart(); } } var gender = gridView.Rows[index].Cells[6].Value.TrimStr(); if (gender == "男") { r["gender"] = 1; } else if (gender == "女") { r["gender"] = 2; } else { r["gender"] = 0; } var remark = gridView.Rows[index].Cells[7].Value.TrimStr(); r["remark"] = remark.Substring(0, Math.Min(remark.Length, 200)); r["origin-type"] = gridView.Rows[index].Cells[8].Value.TrimStr(); var prLevelStr = CrmCommons.PrLevels.FindByText(gridView.Rows[index].Cells[9].Value.TrimStr()); if (prLevelStr != "") { var prLevel = Convert.ToInt32(prLevelStr); if (prLevel > 0) { r["pr-level"] = prLevel; } } var p = CrmInvestor.Create(r).Result; if (p.IsOk) { myGridViewBinding1.BindTo(p, Commons.BindFlag.Update, "ciId"); } return(p); }; dlg.ShowDialog(this); }