示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool             result = true;
            TMerchantTypeDTO sDto   = comboBox2.SelectedItem as TMerchantTypeDTO;

            //新增
            if (sDto == null)
            {
                string           pid = string.Empty;
                TMerchantTypeDTO dto = comboBox1.SelectedItem as TMerchantTypeDTO;
                if (dto != null && string.IsNullOrEmpty(dto.MerchantId) == false)
                {
                    pid = dto.MerchantId;
                }
                sDto = new TMerchantTypeDTO()
                {
                    MerchantId  = Guid.NewGuid().ToString(),
                    MerchatType = comboBox2.Text,
                    MerchantDes = textBox1.Text,
                    ParentId    = pid
                };
                result = _client.TMerchantTypeAdd(sDto);
            }
            else
            {
                result = _client.TMerchantTypeUpdate(sDto);
            }
            if (result)
            {
                //更新
                backgroundWorker1.RunWorkerAsync();
                InitializeCombox();
                MessageBox.Show("保存成功!");
            }
        }
示例#2
0
 /// <summary>
 /// 更新一条TMerchantType记录
 /// </summary>
 /// <param name="dto">TMerchantType实体</param>
 /// <returns>是否更新成功</returns>
 public bool Update(TMerchantTypeDTO dto)
 {
     try
     {
         if (_repository.Update(dto.ProjectedAs <T_MerchantType>()) >= 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#3
0
 /// <summary>
 /// 新增一条TMerchantType记录
 /// </summary>
 /// <param name="dto">TMerchantType实体</param>
 /// <returns>是否新增成功</returns>
 public bool Add(TMerchantTypeDTO dto)
 {
     try
     {
         var entity = dto.ProjectedAs <T_MerchantType>();
         if (_repository.Insert(entity) > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#4
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <TMerchantTypeDTO> source = new List <TMerchantTypeDTO>();

            source.Add(new TMerchantTypeDTO()
            {
                MerchatType = "未知类型"
            });

            TMerchantTypeDTO dto = comboBox1.SelectedItem as TMerchantTypeDTO;

            if (dto != null)
            {
                string             pid    = dto.MerchantId;
                TMerchantTypeDTO[] result = _client.TMerchantTypeGetByPid(pid);
                source.AddRange(result);
            }
            comboBox2.DataSource    = source;
            comboBox2.DisplayMember = "MerchatType";
            comboBox2.ValueMember   = "MerchantId";
        }
示例#5
0
        private void button2_Click(object sender, EventArgs e)
        {
            TMerchantTypeDTO sDto = comboBox2.SelectedItem as TMerchantTypeDTO;

            if (string.IsNullOrEmpty(sDto.MerchantId) == false)
            {
                bool result = _client.TMerchantTypeDelete(sDto.MerchantId);
                if (result)
                {
                    //更新
                    backgroundWorker1.RunWorkerAsync();
                    MessageBox.Show("删除成功!");
                }
            }
            else
            {
                TMerchantTypeDTO dto = comboBox1.SelectedItem as TMerchantTypeDTO;
                if (string.IsNullOrEmpty(dto.MerchantId) == false)
                {
                    //删除所有节点
                    TMerchantTypeDTO[] result = _client.TMerchantTypeGetByPid(dto.MerchantId);
                    foreach (var item in result)
                    {
                        _client.TMerchantTypeDelete(item.MerchantId);
                    }
                    bool result1 = _client.TMerchantTypeDelete(dto.MerchantId);
                    if (result1)
                    {
                        //更新
                        backgroundWorker1.RunWorkerAsync();
                        InitializeCombox();
                        MessageBox.Show("删除成功!");
                    }
                }
            }
        }