Esempio n. 1
0
 private void CopyRow(CustomerDataSet.BasicInfoRow srcRow, CustomerDataSet.BasicInfoRow targetRow)
 {
     foreach (DataColumn col in targetRow.Table.Columns)
     {
         targetRow[col.ColumnName] = srcRow[col.ColumnName];
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 调用方使用该构造函数
 /// </summary>
 /// <param name="formState">当前窗体状态</param>
 /// <param name="basicRow">客户信息行,新增时候为空</param>
 /// <param name="customerService">客户服务接口实例</param>
 public DemoCustomerDetailForm(FormState formState, CustomerDataSet.BasicInfoRow basicRow, ICustomerService customerService)
     : base()
 {
     InitializeComponent();
     this.basicRow        = basicRow;
     this.formState       = formState;
     this.customerService = customerService;
 }
Esempio n. 3
0
        /// <summary>
        /// 打开查看窗体
        /// </summary>
        private void OpenViewForm()
        {
            CustomerDataSet.BasicInfoRow basicRow = GetSelectedRow();
            if (basicRow == null)
            {
                MsgBoxUtility.ShowError("请选择一条记录!");
                return;
            }

            DemoCustomerDetailForm frm = new DemoCustomerDetailForm(FormState.View, basicRow, null);

            frm.ShowDialog();
        }
Esempio n. 4
0
 /// <summary>
 /// 新增客户
 /// </summary>
 /// <param name="basicRow"></param>
 void ICustomerService.Add(CustomerDataSet.BasicInfoRow basicRow)
 {
     // 目前采用模拟的内存数据
     if (this.IsMockTest)
     {
         // 新增客户
         this.mockDataHelper.MockAddCustomer(basicRow);
     }
     else
     {
         // 新增客户
         this.t2DataHelper.AddCustomer(basicRow);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 更新客户
 /// </summary>
 /// <param name="basicRow"></param>
 void ICustomerService.Update(CustomerDataSet.BasicInfoRow basicRow)
 {
     // 目前采用模拟的内存数据
     if (this.IsMockTest)
     {
         //更新客户
         this.mockDataHelper.MockUpdateCustomer(basicRow);
     }
     else
     {
         //更新客户
         this.t2DataHelper.UpdateCustomer(basicRow);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// 初始化界面
        /// </summary>
        void InitForm()
        {
            //如果是新做状态初始化一空行
            if (this.formState == FormState.Add)
            {
                CustomerDataSet.BasicInfoDataTable dt = new CustomerDataSet.BasicInfoDataTable();
                this.basicRow           = dt.NewBasicInfoRow();
                this.basicRow.TradeDate = DateTime.Today;
            }

            //初始化数据绑定
            this.InitDataBindings();

            //绑定界面数据&设置标题
            this.SetUIState();
        }
Esempio n. 7
0
        /// <summary>
        /// 新增客户
        /// </summary>
        /// <param name="basicRow"></param>
        internal void MockAddCustomer(CustomerDataSet.BasicInfoRow basicRow)
        {
            //必须包含客户的基本信息,才能更新数据
            if (basicRow == null)
            {
                throw new ArgumentException("basicRow");
            }
            var targetRow = this.mockCustomers.NewBasicInfoRow();

            CopyRow(basicRow, targetRow);
            //设置Id值
            var maxIdRow = this.mockCustomers.Rows[this.mockCustomers.Rows.Count - 1] as CustomerDataSet.BasicInfoRow;

            targetRow.CustomerID = maxIdRow.CustomerID + 1;
            this.mockCustomers.Rows.Add(targetRow);
            this.mockCustomers.AcceptChanges();
        }
Esempio n. 8
0
        /// <summary>
        /// 编辑按钮单击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolBtnEdit_Click(object sender, EventArgs e)
        {
            CustomerDataSet.BasicInfoRow basicRow = GetSelectedRow();
            if (basicRow == null)
            {
                MsgBoxUtility.ShowError("请选择一条记录!");
                return;
            }

            DemoCustomerDetailForm frm = new DemoCustomerDetailForm(FormState.Edit, basicRow, this.CustomerService);

            //绑定窗体更新成功事件
            frm.UpdateSucceed += (obj, args) =>
            {
                // 记住分页信息的查询客户信息操作然后绑定客户信息
                this.RemeberPagerQueryAndBind();
            };
            frm.ShowDialog();
        }
Esempio n. 9
0
        /// <summary>
        /// 删除按钮单击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolBtnDelete_Click(object sender, EventArgs e)
        {
            CustomerDataSet.BasicInfoRow basicRow = GetSelectedRow();
            if (basicRow == null)
            {
                MsgBoxUtility.ShowError("请选择一条记录!");
                return;
            }
            try
            {
                this.CustomerService.Delete(basicRow.CustomerID);

                // 记住分页信息的查询客户信息操作然后绑定客户信息
                this.RemeberPagerQueryAndBind();
            }
            catch (Exception ex)
            {
                MsgBoxUtility.ShowTips(ex.Message);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 更新客户
        /// </summary>
        /// <param name="customer"></param>
        internal void MockUpdateCustomer(CustomerDataSet.BasicInfoRow basicRow)
        {
            //必须包含客户的基本信息,才能更新数据
            if (basicRow == null)
            {
                throw new ArgumentException("basicRow");
            }

            var dr = mockCustomers.Rows.Find(basicRow.CustomerID) as CustomerDataSet.BasicInfoRow;

            dr.Addr       = basicRow.Addr;
            dr.Email      = basicRow.Email;
            dr.Level      = basicRow.Level;
            dr.Name       = basicRow.Name;
            dr.OfficeTel  = basicRow.OfficeTel;
            dr.Phone      = basicRow.Phone;
            dr.Type       = basicRow.Type;
            dr.TradeDate  = basicRow.TradeDate;
            dr.TradeMoney = basicRow.TradeMoney;
            this.mockCustomers.AcceptChanges();
        }
Esempio n. 11
0
        /// <summary>
        /// 更新客户
        /// </summary>
        /// <param name="basicRow">客户基本信息</param>
        internal void UpdateCustomer(CustomerDataSet.BasicInfoRow basicRow)
        {
            //必须包含客户的基本信息,才能更新数据
            if (basicRow == null)
            {
                throw new ArgumentException("basicRow");
            }

            //****************************************************************
            //如何取得数据,对于T2数据包的封装有各业务系统自己定义。
            //下面的代码只是做个范例之用,不能作为成熟的解决方案
            //简单的将BasicRow 封装成 T2字段列表提供给服务端解析
            var t2Fields = new Dictionary <T2Field, object>();
            var field    = new T2Field("CustomerID", T2FieldType.TYPE_INT);

            t2Fields.Add(field, basicRow.CustomerID);
            field = new T2Field("Addr", T2FieldType.TYPE_STRING);
            t2Fields.Add(field, basicRow.Addr);
            field = new T2Field("CreatedDate", T2FieldType.TYPE_STRING);
            t2Fields.Add(field, basicRow.TradeDate.ToShortDateString());
            field = new T2Field("Email", T2FieldType.TYPE_STRING);
            t2Fields.Add(field, basicRow.Email);
            field = new T2Field("Level", T2FieldType.TYPE_STRING);
            t2Fields.Add(field, basicRow.Level);
            field = new T2Field("Name", T2FieldType.TYPE_STRING);
            t2Fields.Add(field, basicRow.Name);
            field = new T2Field("OfficeTel", T2FieldType.TYPE_STRING);
            t2Fields.Add(field, basicRow.OfficeTel);
            field = new T2Field("Phone", T2FieldType.TYPE_STRING);
            t2Fields.Add(field, basicRow.Phone);
            field = new T2Field("Type", T2FieldType.TYPE_STRING);
            t2Fields.Add(field, basicRow.Type);

            //功能号
            int functionId = 3;

            this.GeneralOperate(functionId, t2Fields);
            //****************************************************************
        }