Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog fdlg = new OpenFileDialog();
            if (DialogResult.OK == fdlg.ShowDialog())
            {
                var excel = new ExcelQueryFactory(fdlg.FileName);
                var indianaCompanies = from c in excel.Worksheet("Sheet1")
                                       select c;
                int ix = 0;
                int il = 0;
                foreach (var item in indianaCompanies)
                {
                    TblInfor newInfo = new TblInfor();

                    string content = "<b>" + item[1].ToString().Trim() + "</b> <br />"
                                    + "" + item[10].ToString().Trim()
                                    + "<br>Khu vực: " + item[9].ToString().Trim()
                                   + "<br>ĐC: " + item[4].ToString().Trim()
                                   + "<br> Số Phòng: " + item[6].ToString().Trim()
                                   + "<br> ĐT: " + item[2].ToString().Trim() + " - FAX: " + item[3].ToString().Trim()
                                   + "<br> Email: " + item[5].ToString().Trim()
                                    + "<br> Chủ đầu tư: " + item[7].ToString().Trim()
                                   + "<br>Giám đốc: " + item[8].ToString().Trim();

                    string tag = "Khách sạn, khach san, ks, " + item[11].ToString().Trim() + ", " + item[2].ToString().Trim();

                    newInfo.CreateDate = DateTime.Now;
                    newInfo.CreateUserID = Guid.Parse("b0b6997c-282b-4aff-b286-b0820cdb0100");
                    newInfo.ID = Guid.NewGuid();
                    newInfo.Category = Categories.KhachSan;
                    newInfo.Location = item[9].ToString().Trim();
                    newInfo.InfoContent = HtmlRemoval.StripTagsRegexCompiled(content);
                    newInfo.InfoContentHtml = content;
                    newInfo.InfoTag = tag;
                    newInfo.InfoTitle = item[1].ToString().Trim() + " " + item[9].ToString().Trim();
                    newInfo.InfoType = InformationType.NoLimit;
                    newInfo.Status = InformationStatus.Approved;

                    newInfo.UpdateDate = DateTime.Now;
                    newInfo.UpdateUserID = Guid.Parse("b0b6997c-282b-4aff-b286-b0820cdb0100");

                    try
                    {
                        BBLInfo b = new BBLInfo();
                        b.InsertOrUpdate(newInfo);

                        ix++;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("E - > " + ex.Message);
                        // DevExpress.XtraEditors.XtraMessageBox.Show(DevExpress.LookAndFeel.UserLookAndFeel.Default, this.FindForm(), ex.Message, "Có sự cố", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        il++;
                    }
                }

                Console.WriteLine(ix + " | " + il);
            }
        }
Пример #2
0
 public CtrlInfoItem(TblInfor data)
 {
     InitializeComponent();
     this.Info = data;
     txtContent.Text = data.InfoContent;
     txtDate.Text = data.UpdateDate.Value.ToString("dd/MM/yyyy hh:mm");
     txtTitle.Text = data.InfoTitle;
 }
Пример #3
0
        public bool Delete(TblInfor data)
        {
            Exception cex = null;
            bool res = false;
            var conn = new System.Data.SqlServerCe.SqlCeConnection(connectionString);
            using (Sonartez_server db = new Sonartez_server(conn))
            {
                var matchedObj = (from c in db.TblInfor
                                  where c.ID == data.ID
                                  select c).SingleOrDefault();

                if (matchedObj != null)
                {
                    try
                    {
                        // does not exist
                        db.TblInfor.DeleteOnSubmit(matchedObj);
                        db.SubmitChanges();
                        res = true;
                    }
                    catch (Exception ex)
                    {
                        cex = ex;
                        res = false;
                    }
                }
                else
                {
                    res = true;
                }
            }

            if (cex != null)
                throw cex;
            else
                return res;
        }
Пример #4
0
        public APIResult UpdateInfor(TblInfor data)
        {
            APIResult res = new APIResult();
            using (Sonartez_server db = new Sonartez_server(connectionString))
            {
                var matchedObj = (from c in db.TblInfor
                                  where c.ID == data.ID
                                  select c).SingleOrDefault();

                if (matchedObj == null)
                {
                    try
                    {
                        // does not exist
                        Table<TblInfor> TblObj = db.TblInfor;
                        data.ServerUpdate = DateTime.Now;
                        TblObj.InsertOnSubmit(data);
                        TblObj.Context.SubmitChanges();

                        res.UpdateDate = data.ServerUpdate.Value;
                        res.Success = true;

                    }
                    catch (Exception ex)
                    {
                        res.Message = ex.Message;
                        res.Success = false;
                    }
                }
                else
                {
                    try
                    {
                        matchedObj.BeginDate = data.BeginDate;
                        matchedObj.CreateDate = data.CreateDate;
                        matchedObj.CreateUserID = data.CreateUserID;
                        matchedObj.ExprieDate = data.ExprieDate;
                        matchedObj.InfoContent = data.InfoContent;
                        matchedObj.InfoTag = data.InfoTag;
                        matchedObj.InfoTitle = data.InfoTitle;
                        matchedObj.InfoType = data.InfoType;
                        matchedObj.Status = data.Status;
                        matchedObj.UpdateDate = data.UpdateDate;
                        matchedObj.ServerUpdate = DateTime.Now;
                        db.SubmitChanges();

                        res.UpdateDate = data.ServerUpdate.Value;
                        res.Success = true;
                    }
                    catch (Exception ex)
                    {
                        res.Message = ex.Message;
                        res.Success = false;
                    }
                }

            }
            return res;
        }
Пример #5
0
 partial void DeleteTblInfor(TblInfor instance);
Пример #6
0
 partial void UpdateTblInfor(TblInfor instance);
Пример #7
0
 partial void InsertTblInfor(TblInfor instance);
Пример #8
0
        private void ShowOnEditForm(TblInfor obj)
        {
            currentSelectedIndex = grvMainInfo.FocusedRowHandle;
            currentInfo = new TblInfor();
            currentInfo = obj;

            txtContent.HtmlText = currentInfo.InfoContentHtml;
            txtInfoTitle.Text = currentInfo.InfoTitle;
            txtTag.Text = currentInfo.InfoTag;

            txtCategory.Text = currentInfo.Category;
            txtLocation.Text = currentInfo.Location;

            if (currentInfo.InfoType == InformationType.Limited)
            {
                chkInfoType.Checked = true;
                dateFrom.Value = currentInfo.BeginDate.Value;
                dateTo.Value = currentInfo.ExprieDate.Value;
            }
            else
            {
                chkInfoType.Checked = false;
            }
            chkStatus.Checked = (currentInfo.Status == InformationStatus.Approved);
        }
Пример #9
0
 private bool DeleteInfo(TblInfor obj)
 {
     try
     {
         obj.IsDeleted = 1;
         info.InsertOrUpdate(obj);
         return true;
     }
     catch (Exception ex)
     {
         DevExpress.XtraEditors.XtraMessageBox.Show(DevExpress.LookAndFeel.UserLookAndFeel.Default, this.FindForm(), ex.Message, "Không thể xóa " + obj.InfoTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
 }
Пример #10
0
        private void btnSaveInfo_Click(object sender, EventArgs e)
        {
            TblInfor newInfo = new TblInfor();

            // Check Data Input
            bool checkInputFlag = true;
            string message = "Thông báo : ";

            if (txtInfoTitle.Text.Trim().Length == 0)
            {
                checkInputFlag = false;
                message += "\n Phải nhập tiêu đề.";
            }

            if (txtContent.Text.Trim().Length == 0)
            {
                checkInputFlag = false;
                message += "\n Phải nhập nội dung.";
            }

            if (chkInfoType.Checked)
                if (dateFrom.Value == null || dateTo.Value == null || dateTo.Value < dateFrom.Value)
                {
                    checkInputFlag = false;
                    message += "\n Giới hạn ngày bắt đầu không được lớn hơn ngày kết thúc";
                }

            if (!checkInputFlag)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(DevExpress.LookAndFeel.UserLookAndFeel.Default, this.FindForm(), message, "Không thể tạo mới", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {

                if (chkInfoType.Checked)
                {
                    newInfo.BeginDate = dateFrom.Value.Date;
                    newInfo.ExprieDate = dateTo.Value.Date.AddHours(23);
                }

                if (createNewFlag)
                {
                    newInfo.CreateDate = DateTime.Now;
                    newInfo.CreateUserID = currentUser.UserID;
                    newInfo.ID = Guid.NewGuid();
                }
                else
                {
                    newInfo.CreateDate = currentInfo.CreateDate;
                    newInfo.CreateUserID = currentInfo.CreateUserID;
                    newInfo.ID = currentInfo.ID;
                }
                newInfo.InfoContent = txtContent.Text.Trim();
                newInfo.InfoContentHtml = txtContent.HtmlText.Trim();
                newInfo.InfoTag = txtTag.Text.Trim();
                newInfo.InfoTitle = txtInfoTitle.Text.Trim();
                newInfo.InfoType = (chkInfoType.Checked) ? InformationType.Limited : InformationType.NoLimit;
                newInfo.Status = (chkStatus.Checked) ? InformationStatus.Approved : InformationStatus.Pending;

                newInfo.Location = cbbLocation.SelectedValue.ToString();
                newInfo.Category = cbbCategory.SelectedValue.ToString();

                newInfo.UpdateDate = DateTime.Now;
                newInfo.UpdateUserID = currentUser.UserID;
                newInfo.IsDeleted = 0;
                try
                {
                    BBLInfo b = new BBLInfo();
                    b.InsertOrUpdate(newInfo);

                    btnDeleteInfo.Visible = false;
                    btnEdit.Visible = false;
                    btnCancelEditInfo.Visible = false;
                    btnSaveInfo.Visible = false;

                    btnCreateInfo.Visible = true;

                    gridControl1.Enabled = true;
                    if (createNewFlag)
                    {
                        createNewFlag = false;
                        currentSelectedIndex = 0;
                    }
                    lstInfo = info.GetAll().Where(x=>x.IsDeleted==0);
                    LoadData();
                    grvMainInfo.FocusedRowHandle = currentSelectedIndex;

                }
                catch (Exception ex)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show(DevExpress.LookAndFeel.UserLookAndFeel.Default, this.FindForm(), ex.Message, "Có sự cố", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

            }
        }
Пример #11
0
        private void ShowOnEditForm(TblInfor obj)
        {
            currentSelectedIndex = grvMainInfo.FocusedRowHandle;
            currentInfo = new TblInfor();
            currentInfo = obj;

            txtContent.HtmlText = currentInfo.InfoContentHtml;
            txtInfoTitle.Text = currentInfo.InfoTitle;
            txtTag.Text = currentInfo.InfoTag;

            if (currentInfo.InfoType == InformationType.Limited)
            {
                chkInfoType.Checked = true;
                dateFrom.Value = currentInfo.BeginDate.Value;
                dateTo.Value = currentInfo.ExprieDate.Value;
            }
            else
            {
                chkInfoType.Checked = false;
            }
            chkStatus.Checked = (currentInfo.Status == InformationStatus.Approved);

            btnDeleteInfo.Visible = true;
            btnEdit.Visible = true;
            btnCancelEditInfo.Visible = false;
            btnSaveInfo.Visible = false;

            btnCreateInfo.Visible = true;
        }
Пример #12
0
        public TblInfor InsertOrUpdate(TblInfor data)
        {
            Exception cex = null;
            TblInfor res = null;
            var conn = new System.Data.SqlServerCe.SqlCeConnection(connectionString);
            using (Sonartez_server db = new Sonartez_server(conn))
            {
                var matchedObj = (from c in db.TblInfor
                                  where c.ID == data.ID
                                  select c).SingleOrDefault();

                if (matchedObj == null)
                {
                    try
                    {
                        // does not exist
                        Table<TblInfor> TblObj = db.TblInfor;
                        data.UpdateDate = DateTime.Now;
                        data.IsDeleted = 0;
                        TblObj.InsertOnSubmit(data);
                        TblObj.Context.SubmitChanges();
                        res = data;
                    }
                    catch (Exception ex)
                    {
                        cex = ex;
                    }
                }
                else
                {
                    try
                    {
                        matchedObj.BeginDate = data.BeginDate;
                        matchedObj.CreateDate = data.CreateDate;
                        matchedObj.CreateUserID = data.CreateUserID;
                        matchedObj.ExprieDate = data.ExprieDate;
                        matchedObj.InfoContentHtml = data.InfoContentHtml;
                        matchedObj.InfoContent = data.InfoContent;
                        matchedObj.InfoTag = data.InfoTag;
                        matchedObj.InfoTitle = data.InfoTitle;
                        matchedObj.InfoType = data.InfoType;
                        matchedObj.Location = data.Location;
                        matchedObj.Category = data.Category;
                        matchedObj.Status = data.Status;
                        matchedObj.UpdateDate = DateTime.Now;
                        matchedObj.IsDeleted = data.IsDeleted;
                        db.SubmitChanges();
                        res = matchedObj;

                    }
                    catch (Exception ex)
                    {
                        cex = ex;
                    }
                }

            }

            if (cex != null)
                throw cex;
            else
                return res;
        }
Пример #13
0
        // Ngân hàng ATM
        private void button8_Click(object sender, EventArgs e)
        {
            OpenFileDialog fdlg = new OpenFileDialog();
            if (DialogResult.OK == fdlg.ShowDialog())
            {
                var excel = new ExcelQueryFactory(fdlg.FileName);
                var indianaCompanies = from c in excel.Worksheet("Sheet1")
                                       select c;
                int ix = 0;
                int il = 0;
                foreach (var item in indianaCompanies)
                {
                    TblInfor newInfo = new TblInfor();

                    string content = "<b>" + item[5].ToString().Trim() +" "+ item[1].ToString().Trim() + "</b> "
                                    + "<br><i>" + item[4].ToString().Trim() + "</i>"

                                   + "<br><u>Địa chỉ</u>:<br> " + item[2].ToString().Trim()
                                   + "<br><u>Điện thoại</u>: " + item[3].ToString().Trim();

                    string tag = "ATM, Ngân Hàng, Bank";

                    newInfo.CreateDate = DateTime.Now;
                    newInfo.CreateUserID = Guid.Parse("b0b6997c-282b-4aff-b286-b0820cdb0100");
                    newInfo.ID = Guid.NewGuid();
                    newInfo.IsDeleted = 0;
                    newInfo.InfoContent = HtmlRemoval.StripTagsRegexCompiled(content);
                    newInfo.InfoContentHtml = content;
                    newInfo.InfoTag = tag;
                    newInfo.InfoTitle =item[5].ToString().Trim() +" "+ item[1].ToString().Trim();
                    newInfo.InfoType = InformationType.NoLimit;
                    newInfo.Status = InformationStatus.Approved;
                    newInfo.Category = Categories.NganHang;
                    newInfo.Location = item[6].ToString().Trim();
                    newInfo.UpdateDate = DateTime.Now;
                    newInfo.UpdateUserID = Guid.Parse("b0b6997c-282b-4aff-b286-b0820cdb0100");

                    try
                    {
                        BBLInfo b = new BBLInfo();
                        b.InsertOrUpdate(newInfo);

                        ix++;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("E - > " + ex.Message);
                        // DevExpress.XtraEditors.XtraMessageBox.Show(DevExpress.LookAndFeel.UserLookAndFeel.Default, this.FindForm(), ex.Message, "Có sự cố", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        il++;
                    }
                }

                Console.WriteLine(ix + " | " + il);
            }
        }
Пример #14
0
        private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog fdlg = new OpenFileDialog();
            if (DialogResult.OK == fdlg.ShowDialog())
            {
                var excel = new ExcelQueryFactory(fdlg.FileName);
                var indianaCompanies = from c in excel.Worksheet("Sheet1")
                                       select c;
                int ix = 0;
                int il = 0;
                foreach (var item in indianaCompanies)
                {
                    TblInfor newInfo = new TblInfor();

                    string content = "<b>" + item[0].ToString().Trim() + "</b>  Số hiệu :" + item[2].ToString().Trim()
                                    + "<br>Tần suất: " + item[4].ToString().Trim() + " Giá vé : " + item[7].ToString().Trim()
                                   + "<br>Tuyến đường: " + item[3].ToString().Trim()
                                   + "<br>Thời gian hoạt động: " + item[6].ToString().Trim() + " Số chuyến/ngày: " + item[5].ToString().Trim()
                                   + "<br>Đơn vị: " + item[1].ToString().Trim()
                                   + "<br>ĐT: " + item[8].ToString().Trim();

                    string tag = "xe, vận tải, dịch vụ ";

                    newInfo.CreateDate = DateTime.Now;
                    newInfo.CreateUserID = Guid.Parse("b0b6997c-282b-4aff-b286-b0820cdb0100");
                    newInfo.ID = Guid.NewGuid();
                    newInfo.IsDeleted = 0;
                    newInfo.InfoContent = HtmlRemoval.StripTagsRegexCompiled(content);
                    newInfo.InfoContentHtml = content;
                    newInfo.InfoTag = tag;
                    newInfo.InfoTitle = item[0].ToString().Trim();
                    newInfo.InfoType = InformationType.NoLimit;
                    newInfo.Status = InformationStatus.Approved;

                    newInfo.UpdateDate = DateTime.Now;
                    newInfo.UpdateUserID = Guid.Parse("b0b6997c-282b-4aff-b286-b0820cdb0100");

                    try
                    {
                        BBLInfo b = new BBLInfo();
                        b.InsertOrUpdate(newInfo);

                        ix++;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("E - > " + ex.Message);
                        // DevExpress.XtraEditors.XtraMessageBox.Show(DevExpress.LookAndFeel.UserLookAndFeel.Default, this.FindForm(), ex.Message, "Có sự cố", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        il++;
                    }
                }

                Console.WriteLine(ix + " | " + il);
            }
        }