Example #1
0
 /// <summary>
 /// 删除一个车辆照片并把对应的登记信息关联改为null
 /// </summary>
 /// <param name="info">车辆照片信息</param>
 /// <returns>是否成功</returns>
 public bool Delete(VehiclePhoto info)
 {
     string[] array = new string[1];
     array[0] = "delete from table_vehicle_photo where id=" + info.Id;
     //array[1] = "update cardetail where photoid=" + info.Id;
     return(this.access.ExecuteTransaction(array));
 }
Example #2
0
 /// <summary>
 /// ɾ��һ��������Ƭ���Ѷ�Ӧ�ĵǼ���Ϣ������Ϊnull
 /// </summary>
 /// <param name="info">������Ƭ��Ϣ</param>
 /// <returns>�Ƿ�ɹ�</returns>
 public bool Delete(VehiclePhoto info)
 {
     string[] array = new string[1];
     array[0] = "delete from table_vehicle_photo where id=" + info.Id;
     //array[1] = "update cardetail where photoid=" + info.Id;
     return this.access.ExecuteTransaction(array);
 }
Example #3
0
 public PhotoSelector(VehicleBrowser parent, string oldxuhao, string oldpinp, string oldxh)
 {
     InitializeComponent();
     this.parentForm = parent;
     this.xuhao      = oldxuhao;
     this.oldpinp    = oldpinp;
     this.oldxh      = oldxh;
     if (!this.DesignMode)
     {
         Vehicle.Plugins.BindHelper.BindZwpp(this.cbClassical);
         this.cbClassical.Text = oldpinp;
         this.cbType.Text      = oldxh;
         this.Search();
         VehiclePhoto temp = null;
         for (int i = 0; i < this.photos.Count; i++)
         {
             temp = this.photos[i] as VehiclePhoto;
             if (temp.XuHao == this.xuhao)
             {
                 this.listView1.Items[i].Selected = true;
                 break;
             }
         }
         //this.cbClassical.DropDownStyle = ComboBoxStyle.DropDown;
     }
 }
Example #4
0
 /// <summary>
 /// ����һ��������Ƭ��Ϣ
 /// </summary>
 /// <param name="info">������Ƭ��Ϣ</param>
 /// <returns>�Ƿ�ɹ�����</returns>
 public bool Add(VehiclePhoto info)
 {
     info.XuHao = this.GetXuHao();
     string sql = "insert into table_vehicle_photo(cn_classical,cn_type,suffix,xuhao) values('" +
         DALSecurityTool.TransferInsertField(info.Cn_Classical) + "','" +
         DALSecurityTool.TransferInsertField(info.Cn_Type) + "','" +
         DALSecurityTool.TransferInsertField(info.Suffix) + "','" +
         DALSecurityTool.TransferInsertField(info.XuHao) + "')";
     return this.access.ExecuteSql(sql);
 }
Example #5
0
        /// <summary>
        /// 增加一个车辆照片信息
        /// </summary>
        /// <param name="info">车辆照片信息</param>
        /// <returns>是否成功增加</returns>
        public bool Add(VehiclePhoto info)
        {
            info.XuHao = this.GetXuHao();
            string sql = "insert into table_vehicle_photo(cn_classical,cn_type,suffix,xuhao) values('" +
                         DALSecurityTool.TransferInsertField(info.Cn_Classical) + "','" +
                         DALSecurityTool.TransferInsertField(info.Cn_Type) + "','" +
                         DALSecurityTool.TransferInsertField(info.Suffix) + "','" +
                         DALSecurityTool.TransferInsertField(info.XuHao) + "')";

            return(this.access.ExecuteSql(sql));
        }
Example #6
0
 private void listView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.listView1.SelectedIndices != null && this.listView1.SelectedIndices.Count == 1)
     {
         VehiclePhoto temp = this.photos[this.listView1.SelectedIndices[0]] as VehiclePhoto;
         this.picPhoto.Image   = temp.Picture;
         this.cbClassical.Text = temp.Cn_Classical;
         //this.cbType.Text = temp.Cn_Type;
         // this.suffix = temp.Suffix;
     }
 }
Example #7
0
        /// <summary>
        /// 重新获取查询结果集合数据到ListView上
        /// </summary>
        private void ReloadCollection()
        {
            this.listView1.Items.Clear();
            VehiclePhoto temp = null;

            for (int i = 0; i < this.photos.Count; i++)
            {
                temp = this.photos[i] as VehiclePhoto;
                this.listView1.Items.Add(new ListViewItem(new string[] { temp.Cn_Classical, temp.Cn_Type }));
            }
        }
Example #8
0
        /// <summary>
        /// 从DataRow生成一个table_vehicle_photo对象
        /// </summary>
        /// <param name="dr">DataRow对象</param>
        /// <returns>一个table_vehicle_photo对象</returns>
        private static VehiclePhoto GetFromDataRow(DataRow dr)
        {
            VehiclePhoto temp = new VehiclePhoto();

            temp.Id           = dr["id"].ToString();
            temp.Cn_Classical = dr["cn_classical"].ToString();
            temp.Cn_Type      = dr["cn_type"].ToString();
            temp.Suffix       = dr["suffix"].ToString();
            temp.XuHao        = dr["xuhao"].ToString();
            if (dr["picture"] != null && !(dr["picture"] is DBNull))
            {
                byte[] by = (byte[])dr["picture"];

                MemoryStream mss = new MemoryStream(by);

                temp.Picture = Image.FromStream(mss);
            }
            return(temp);
        }
Example #9
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (this.listView1.SelectedIndices != null && this.listView1.SelectedIndices.Count == 1)
     {
         VehiclePhoto temp = this.photos[this.listView1.SelectedIndices[0]] as VehiclePhoto;
         if (MessageBoxHelper.Confirm("确定删除" + temp.Cn_Classical + "-" + temp.Cn_Type + "吗?"))
         {
             VehiclePhotoAccess access = new VehiclePhotoAccess();
             if (access.Delete(temp))
             {
                 this.photos.RemoveAt(this.listView1.SelectedIndices[0]);
                 this.listView1.Items.Remove(this.listView1.SelectedItems[0]);
             }
         }
     }
     else
     {
         MessageBoxHelper.Show("请先选中需要删除的照片!");
     }
 }
Example #10
0
        /// <summary>
        /// ��DataRow����һ��table_vehicle_photo����
        /// </summary>
        /// <param name="dr">DataRow����</param>
        /// <returns>һ��table_vehicle_photo����</returns>
        private static VehiclePhoto GetFromDataRow(DataRow dr)
        {
            VehiclePhoto temp = new VehiclePhoto();
            temp.Id = dr["id"].ToString();
            temp.Cn_Classical = dr["cn_classical"].ToString();
            temp.Cn_Type = dr["cn_type"].ToString();
            temp.Suffix = dr["suffix"].ToString();
            temp.XuHao = dr["xuhao"].ToString();
            if (dr["picture"] != null && !(dr["picture"] is DBNull))
            {
                byte[] by = (byte[])dr["picture"];

                MemoryStream mss = new MemoryStream(by);

                temp.Picture = Image.FromStream(mss);
            }
            return temp;
        }
Example #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.picPhoto.Image == null)
            {
                MessageBoxHelper.Show("请先选择一个照片!");
                return;
            }
            string classical = this.cbClassical.Text.Trim();
            string type      = this.cbType.Text.Trim();

            if (classical == string.Empty || classical == "请选择")
            {
                MessageBoxHelper.Show("请选择或者输入中文品牌!");
                return;
            }
            if (type == string.Empty || type == "请选择")
            {
                MessageBoxHelper.Show("请选择或者输入车辆型号!");
                return;
            }
            VehiclePhotoAccess access = new VehiclePhotoAccess();
            VehiclePhoto       photo  = new VehiclePhoto();

            photo.Cn_Classical = classical;
            photo.Cn_Type      = type;
            photo.Picture      = this.picPhoto.Image;
            photo.Suffix       = this.suffix;
            bool result = access.Add(photo);

            if (result)
            {
                if (access.UpdateImage(access.GetLasted().Id, photo.Picture))
                {
                    object obj = access.ExecuteScalar("select count(*) from table_dict where c_grouptype='中文品牌' and c_text='" + this.cbClassical.Text + "'");
                    if (Convert.ToInt32(obj) == 0)
                    {
                        Dict temp = new Dict();
                        temp.Text        = this.cbClassical.Text;
                        temp.Value       = this.cbClassical.Text;
                        temp.Valid       = "有效";
                        temp.GroupType   = "中文品牌";
                        temp.Description = temp.Text;
                        FT.DAL.Orm.SimpleOrmOperator.Create(temp);
                        ArrayList lists = this.cbClassical.DataSource as ArrayList;
                        lists.Add(temp);
                        this.cbClassical.DataSource = lists;
                        //this.cbClassical.Items.Add(temp.Text);
                    }
                    object obj2 = access.ExecuteScalar("select count(*) from table_dict where c_grouptype='车辆型号' and c_text='" + this.cbType.Text + "'");
                    if (Convert.ToInt32(obj2) == 0)
                    {
                        Dict temp = new Dict();
                        temp.Text        = this.cbType.Text;
                        temp.Value       = this.cbType.Text;
                        temp.Valid       = "有效";
                        temp.GroupType   = "车辆型号";
                        temp.Description = this.cbClassical.Text;
                        FT.DAL.Orm.SimpleOrmOperator.Create(temp);
                        ArrayList lists = this.cbType.DataSource as ArrayList;
                        lists.Add(temp);
                        this.cbType.DataSource = lists;
                        //this.cbType.Items.Add(temp.Text);
                    }
                    MessageBoxHelper.Show("添加成功!");
                    //Constant.InitCbCnClassical(this.cbClassical);
                }
                else
                {
                    MessageBoxHelper.Show("更新图片过程失败!");
                }
            }
            else
            {
                MessageBoxHelper.Show("添加数据失败!");
            }
        }
Example #12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.picPhoto.Image == null)
            {
                MessageBoxHelper.Show("����ѡ��һ����Ƭ��");
                return;
            }
            string classical = this.cbClassical.Text.Trim();
            string type = this.cbType.Text.Trim();
            if (classical == string.Empty || classical == "��ѡ��")
            {
                MessageBoxHelper.Show("��ѡ�������������Ʒ�ƣ�");
                return;

            }
            if (type == string.Empty || type == "��ѡ��")
            {
                MessageBoxHelper.Show("��ѡ��������복���ͺţ�");
                return;
            }
            VehiclePhotoAccess access = new VehiclePhotoAccess();
            VehiclePhoto photo = new VehiclePhoto();
            photo.Cn_Classical = classical;
            photo.Cn_Type = type;
            photo.Picture = this.picPhoto.Image;
            photo.Suffix = this.suffix;
            bool result = access.Add(photo);
            if (result)
            {
                if (access.UpdateImage(access.GetLasted().Id, photo.Picture))
                {
                    object obj=access.ExecuteScalar("select count(*) from table_dict where c_grouptype='����Ʒ��' and c_text='" + this.cbClassical.Text + "'");
                    if (Convert.ToInt32(obj) == 0)
                    {
                        Dict temp = new Dict();
                        temp.Text = this.cbClassical.Text;
                        temp.Value = this.cbClassical.Text;
                        temp.Valid = "��Ч";
                        temp.GroupType = "����Ʒ��";
                        temp.Description = temp.Text;
                        FT.DAL.Orm.SimpleOrmOperator.Create(temp);
                        ArrayList lists = this.cbClassical.DataSource as ArrayList;
                        lists.Add(temp);
                        this.cbClassical.DataSource = lists;
                        //this.cbClassical.Items.Add(temp.Text);
                    }
                    object obj2 = access.ExecuteScalar("select count(*) from table_dict where c_grouptype='�����ͺ�' and c_text='" + this.cbType.Text + "'");
                    if (Convert.ToInt32(obj2) == 0)
                    {
                        Dict temp = new Dict();
                        temp.Text = this.cbType.Text;
                        temp.Value = this.cbType.Text;
                        temp.Valid = "��Ч";
                        temp.GroupType = "�����ͺ�";
                        temp.Description = this.cbClassical.Text;
                        FT.DAL.Orm.SimpleOrmOperator.Create(temp);
                        ArrayList lists = this.cbType.DataSource as ArrayList;
                        lists.Add(temp);
                        this.cbType.DataSource = lists;
                        //this.cbType.Items.Add(temp.Text);
                    }
                    MessageBoxHelper.Show("��ӳɹ���");
                    //Constant.InitCbCnClassical(this.cbClassical);
                }
                else
                {
                    MessageBoxHelper.Show("����ͼƬ����ʧ�ܣ�");
                }

            }
            else
            {
                MessageBoxHelper.Show("�������ʧ�ܣ�");
            }
        }