Esempio n. 1
0
        private thongbaokiemtra KiemTraSoLieu(dienthoai_new model)
        {
            try
            {
                if (!TestTelNumber(model.didong))
                {
                    return new thongbaokiemtra()
                           {
                               trangthai = false, NoiDung = "Điện thoại không đúng format"
                           }
                }
                ;


                if (model.gioi_tinhold != "")
                {
                    if (model.gioi_tinhold != "0" || model.gioi_tinhold != "1" || model.gioi_tinhold.ToLower() != "trai" || model.gioi_tinhold.ToLower() != "nữ" || model.gioi_tinhold.ToLower() != "nu" ||
                        model.gioi_tinhold.ToLower() != "true" || model.gioi_tinhold.ToLower() != "false")
                    {
                        return new thongbaokiemtra()
                               {
                                   trangthai = false, NoiDung = "Giới tính không đúng format [Nam|Nữ];[0|1];[trai|gai];[true|false]"
                               }
                    }
                }
                ;
                return(new thongbaokiemtra()
                {
                    trangthai = true, NoiDung = "Số liệu đúng"
                });
            }
            catch (Exception ex)
            {
                return(new thongbaokiemtra()
                {
                    trangthai = false, NoiDung = ex.Message
                });
            }
        }
Esempio n. 2
0
        public static bool UpdateDienThoaiNEW(dienthoai_new record)
        {
            SqlConnection connection = null;
            SqlCommand    cmd        = null;

            try
            {
                if (record == null)
                {
                    return(false);
                }

                // Make connection to database
                connection = new SqlConnection();
                connection.ConnectionString = ConnectionString;
                connection.FireInfoMessageEventOnUserErrors = false;
                connection.Open();
                // Create command to update GeneralGuessGroup record
                cmd             = new SqlCommand();
                cmd.Connection  = connection;
                cmd.CommandText = "Update dienthoai_goc Set ten_khach_hang=@ten_khach_hang, "
                                  + "dia_chi=@dia_chi,namsinh=@namsinh,ngay=@ngay,thang=@thang,cuoc=@cuoc, "
                                  + "ngan_hang=@ngan_hang, sim=@sim,tinh_cuoc=@tinh_cuoc ,tinh=@tinh,phuong=@phuong,quan_huyen=@quan_huyen,email=@email,ngay_kich_hoat=@ngay_kich_hoat,goi_cuoc=@goi_cuoc,dong_may=@dong_may,he_dieu_hanh=@he_dieu_hanh,chuc_vu=@chuc_vu,cong_ty=@cong_ty"
                                  + " where ID='" + record.id + "'";
                cmd.CommandType = CommandType.Text;

                cmd.Parameters.AddWithValue("@ten_khach_hang", record.ten_khach_hang);
                cmd.Parameters.AddWithValue("@didong", record.didong);
                cmd.Parameters.AddWithValue("@dia_chi", record.dia_chi);
                cmd.Parameters.AddWithValue("@phuong", record.phuong);
                cmd.Parameters.AddWithValue("@quan_huyen", record.quan_huyen);
                cmd.Parameters.AddWithValue("@email", record.email);
                cmd.Parameters.AddWithValue("@namsinh", record.namsinh);
                cmd.Parameters.AddWithValue("@ngay", record.ngay);
                cmd.Parameters.AddWithValue("@thang", record.thang);
                cmd.Parameters.AddWithValue("@cuoc", record.cuoc);
                cmd.Parameters.AddWithValue("@ngan_hang", record.ngan_hang);
                cmd.Parameters.AddWithValue("@sim", record.sim);
                cmd.Parameters.AddWithValue("@tinh", record.tinh);
                cmd.Parameters.AddWithValue("@tinh_cuoc", record.tinh_cuoc);
                cmd.Parameters.AddWithValue("@ghi_chu", record.ghi_chu);
                cmd.Parameters.AddWithValue("@filenguon", record.filenguon);
                cmd.Parameters.AddWithValue("@gioi_tinh", record.gioi_tinh);
                cmd.Parameters.AddWithValue("@ngay_kich_hoat", record.ngay_kich_hoat);
                cmd.Parameters.AddWithValue("@goi_cuoc", record.goi_cuoc);
                cmd.Parameters.AddWithValue("@dong_may", record.dong_may);
                cmd.Parameters.AddWithValue("@he_dieu_hanh", record.he_dieu_hanh);
                cmd.Parameters.AddWithValue("@chuc_vu", record.chuc_vu);
                cmd.Parameters.AddWithValue("@cong_ty", record.cong_ty);


                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "UpdateDienThoaiNEW");
                return(false);
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
        }
Esempio n. 3
0
        //----- Process Import File Text
        private void ProcessImportFileText(object arrControl)
        {
            StreamReader sReader;

            countInsert = 0;
            int    process   = 0;
            int    countErro = 0;
            object totalRow;
            string line;

            string[] lineParts, countLines;
            char[]   charSpits;

            try
            {
                //----- Add control process from
                ArrayList    arr1              = (ArrayList)arrControl;
                Label        lb_title1         = (Label)arr1[0];
                Label        pictureBox_title1 = (Label)arr1[1];
                NeroBar      progressBar11     = (NeroBar)arr1[2];
                Button       btn_Stop1         = (Button)arr1[3];
                DataGridView gridview1         = (DataGridView)arr1[4];
                TabControl   tabControl1       = (TabControl)arr1[5];
                RichTextBox  richTextBox1      = (RichTextBox)arr1[6];
                Button       btn_xuat1         = (Button)arr1[7];

                //----- update display control
                lb_title1.Update();

                btn_Stop1.Update();
                gridview1.Update();

                //----- Get Total row
                countLines = File.ReadAllLines(connectionString);
                totalRow   = countLines.Length;
                if (totalRow == null)
                {
                    return;
                }

                //----- Get Data from Source
                progressBar11.MaxValue = int.Parse(totalRow.ToString());
                progressBar11.MinValue = 0;


                sReader   = new StreamReader(connectionString);
                charSpits = (new char[] { charSpit }); //charSpit.ToCharArray();
                while ((line = sReader.ReadLine()) != null)
                {
                    //----- Stop process if false
                    if (hasProcess)
                    {
                        process++;
                        lineParts = line.Split(charSpits);
                        //----- Test value import
                        dienthoai_new model = new dienthoai_new();
                        if (dict.FirstOrDefault(x => x.Key == "cbb_TelNumber").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_TelNumber").Value))
                            {
                                model.didong = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_TelNumber").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_ten_khach_hang").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_ten_khach_hang").Value))
                            {
                                model.ten_khach_hang = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_ten_khach_hang").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_dia_chi").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_dia_chi").Value))
                            {
                                model.dia_chi = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_dia_chi").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_Ngay").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_Ngay").Value))
                            {
                                model.ngay = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_Ngay").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_Thang").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_Thang").Value))
                            {
                                model.thang = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_Thang").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_gioitinh").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_gioitinh").Value))
                            {
                                model.gioi_tinh = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_gioitinh").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_namsinh").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_namsinh").Value))
                            {
                                model.namsinh = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_namsinh").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_nganhang").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_nganhang").Value))
                            {
                                model.ngan_hang = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_nganhang").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_cuoc").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_cuoc").Value))
                            {
                                model.cuoc = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_cuoc").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_sim").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_sim").Value))
                            {
                                model.sim = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_sim").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_tinh").Value != "")
                        {
                            if (lineParts.Count() >= Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_tinh").Value))
                            {
                                model.tinh = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_tinh").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_tinhcuoc").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_tinhcuoc").Value))
                            {
                                model.tinh_cuoc = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_tinhcuoc").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_ghichu").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_ghichu").Value))
                            {
                                model.ghi_chu = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_ghichu").Value)].Trim();
                            }
                        }
                        /*---------------------------------------------*/
                        if (dict.FirstOrDefault(x => x.Key == "cbb_phuong").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_phuong").Value))
                            {
                                model.phuong = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_phuong").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_quanhuyen").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_quanhuyen").Value))
                            {
                                model.quan_huyen = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_quanhuyen").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_email").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_email").Value))
                            {
                                model.email = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_email").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_ngay_kich_hoat").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_ngay_kich_hoat").Value))
                            {
                                model.ngay_kich_hoat = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_ngay_kich_hoat").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_goiCuoc").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_goiCuoc").Value))
                            {
                                model.goi_cuoc = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_goiCuoc").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_dongmay").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_dongmay").Value))
                            {
                                model.dong_may = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_dongmay").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_hedieuhanh").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_hedieuhanh").Value))
                            {
                                model.he_dieu_hanh = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_hedieuhanh").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_chucvu").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_chucvu").Value))
                            {
                                model.chuc_vu = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_chucvu").Value)].Trim();
                            }
                        }
                        if (dict.FirstOrDefault(x => x.Key == "cbb_congty").Value != "")
                        {
                            if (lineParts.Count() > Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_congty").Value))
                            {
                                model.cong_ty = lineParts[Convert.ToInt32(dict.FirstOrDefault(x => x.Key == "cbb_congty").Value)].Trim();
                            }
                        }

                        model.filenguon = nguon;
                        thongbaokiemtra kq = KiemTraSoLieu(model);
                        if (kq.trangthai)
                        {
                            //----- Test exists in database
                            int nloi = 0;
                            //if(kiemtra)
                            //    nloi = TestTelNumberExists(model.didong);
                            if (nloi == 0)
                            {
                                //----- Insert to TelNumberChange Table
                                if (SQLDatabase.AddDienThoaiNEW(model) == true)
                                {
                                    countInsert++;
                                }
                                else
                                {
                                    tberror.Rows.Add(process, model.didong, "Sai định dạng.");
                                    countErro++;
                                }
                            }
                            else
                            {
                                tberror.Rows.Add(process, model.didong, "Đã tồn tại");
                                countErro++;
                                /*da ton tai*/
                            }
                        }
                        else   /*loi*/
                        {
                            tberror.Rows.Add(process, model.didong, kq.NoiDung);
                            countErro++;
                        }
                        ShowMessage(ref richTextBox1, process, countErro, countInsert, int.Parse(totalRow.ToString()));
                        tabControl1.TabPages[1].Text = string.Format("Error {0}", countErro);
                        tabControl1.Update();

                        progressBar11.Value = process;
                        progressBar11.Update();
                        Thread.Sleep(0);
                    }
                }



                if (countErro == 0)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }

                btn_Stop1.Text   = "Đóng";
                btn_xuat.Enabled = true;
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "ProcessImportFileText", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Esempio n. 4
0
        public static bool AddDienThoaiNEW(dienthoai_new record)
        {
            SqlConnection cnn = null;
            SqlCommand    cmd = null;

            object objectID;

            try
            {
                if (record == null)
                {
                    return(false);
                }

                cnn = new SqlConnection();
                cnn.ConnectionString = ConnectionString;
                cnn.FireInfoMessageEventOnUserErrors = false;
                cnn.Open();

                cmd            = new SqlCommand();
                cmd.Connection = cnn;
                //--- Insert Record
                cmd.CommandText = "Insert into dienthoai_new(ten_khach_hang,phuong,quan_huyen, didong, dia_chi, namsinh,email, ngay,thang,cuoc, gioi_tinh, ngan_hang, sim, tinh, ghi_chu,  filenguon,tinh_cuoc,ngay_kich_hoat,goi_cuoc,dong_may,he_dieu_hanh,chuc_vu,cong_ty)" +
                                  "values(@ten_khach_hang,@phuong,@quan_huyen, @didong, @dia_chi, @namsinh,@email, @ngay,@thang,@cuoc, @gioi_tinh, @ngan_hang, @sim, @tinh, @ghi_chu,  @filenguon,@tinh_cuoc,@ngay_kich_hoat,@goi_cuoc,@dong_may,@he_dieu_hanh,@chuc_vu,@cong_ty);" +
                                  "Select SCOPE_IDENTITY();";

                cmd.Parameters.AddWithValue("@ten_khach_hang", record.ten_khach_hang);
                cmd.Parameters.AddWithValue("@didong", record.didong);
                cmd.Parameters.AddWithValue("@dia_chi", record.dia_chi);
                cmd.Parameters.AddWithValue("@phuong", record.phuong);
                cmd.Parameters.AddWithValue("@quan_huyen", record.quan_huyen);
                cmd.Parameters.AddWithValue("@email", record.email);
                cmd.Parameters.AddWithValue("@namsinh", record.namsinh);
                cmd.Parameters.AddWithValue("@ngay", record.ngay);
                cmd.Parameters.AddWithValue("@thang", record.thang);
                cmd.Parameters.AddWithValue("@cuoc", record.cuoc);
                cmd.Parameters.AddWithValue("@ngan_hang", record.ngan_hang);
                cmd.Parameters.AddWithValue("@sim", record.sim);
                cmd.Parameters.AddWithValue("@tinh", record.tinh);
                cmd.Parameters.AddWithValue("@tinh_cuoc", record.tinh_cuoc);
                cmd.Parameters.AddWithValue("@ghi_chu", record.ghi_chu);
                cmd.Parameters.AddWithValue("@filenguon", record.filenguon);
                cmd.Parameters.AddWithValue("@gioi_tinh", record.gioi_tinh);
                cmd.Parameters.AddWithValue("@ngay_kich_hoat", record.ngay_kich_hoat);
                cmd.Parameters.AddWithValue("@goi_cuoc", record.goi_cuoc);
                cmd.Parameters.AddWithValue("@dong_may", record.dong_may);
                cmd.Parameters.AddWithValue("@he_dieu_hanh", record.he_dieu_hanh);
                cmd.Parameters.AddWithValue("@chuc_vu", record.chuc_vu);
                cmd.Parameters.AddWithValue("@cong_ty", record.cong_ty);


                objectID = cmd.ExecuteScalar();

                if (objectID == null || objectID == DBNull.Value)
                {
                    return(false);
                }

                record.id = Convert.ToInt32(objectID);

                return(true);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                return(false);
            }
            finally
            {
                if (cnn.State == ConnectionState.Open)
                {
                    cnn.Close();
                }
            }
        }