Пример #1
0
        public virtual void Import_Excel(bool CheckAPI)
        {
            bool bIsImport = DataTool.SQLCheckExist("sys.procedures", "Name", "OM_Import_PromotionBudget");

            if (bIsImport)
            {
                SqlCommand command = SQLExec.GetNewSQLConnection().CreateCommand();
                command.CommandText = "OM_Import_PJP";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Ma_DvCs", Element.sysMa_DvCs);
                SqlParameter parameter = new SqlParameter
                {
                    SqlDbType     = SqlDbType.Structured,
                    ParameterName = "@TablePJP",
                    TypeName      = "TVP_OMPJP",
                    Value         = dtImport
                };
                command.Parameters.Add(parameter);
                try
                {
                    command.ExecuteNonQuery();
                }
                catch (Exception exception)
                {
                    command.CommandText = "WHILE @@TRANCOUNT > 0 ROLLBACK TRANSACTION";
                    command.CommandType = CommandType.Text;
                    command.Parameters.Clear();
                    command.ExecuteNonQuery();
                    EpointProcessBox.AddMessage("Có lỗi xảy ra :" + exception.Message);
                }
            }

            EpointProcessBox.AddMessage("Kết thúc");
        }
Пример #2
0
        private void KetChuyen_Delete()
        {
            dgvKetChuyen.EndEdit();
            bdsKetChuyen.EndEdit();

            //if (Common.GetPartitionCurrent() != 0 && Common.GetPartitionCurrent() != Element.sysWorkingYear)
            //{
            //    Common.MsgCancel("Phải chuyển về phân vùng dữ liệu " + Element.sysWorkingYear.ToString() + "!");
            //    return;
            //}

            //frmKetChuyen_Run frm = new frmKetChuyen_Run();
            //frm.Tag = "Ket_Chuyen_Delete";
            //frm.numThang1.Value = Element.sysNgay_Ct1.Month;
            //frm.numThang2.Value = Element.sysNgay_Ct2.Month;

            //frm.Load();
            //if (!frm.isAccept)
            //    return;

            //DateTime dteNgay_Ct1 = Library.StrToDate("01/" + frm.numThang1.Value + "/" + Element.sysWorkingYear);
            //DateTime dteNgay_Ct2 = Library.StrToDate("01/" + frm.numThang2.Value + "/" + Element.sysWorkingYear);
            //dteNgay_Ct2 = dteNgay_Ct2.AddMonths(1).AddDays(-1);

            EpointProcessBox.setMaxValue(dgvKetChuyen.Rows.Count);

            if (!Common.CheckDataLocked(dteNgay_Ct1))
            {
                //Common.MsgCancel("Dữ liệu đã khóa, liên hệ với nhà quản trị!");
                EpointProcessBox.AddMessage(EpointMessage.GetMessage("DATALOCK"));
                return;
            }

            foreach (DataRow dr in dtKetChuyen.Rows)
            {
                if ((bool)dr["SELECT"] == false)
                {
                    continue;
                }

                Hashtable ht = new Hashtable();
                ht["NGAY_CT1"] = dteNgay_Ct1;
                ht["NGAY_CT2"] = dteNgay_Ct2;
                ht["STT"]      = dr["Stt"];
                ht["MA_CT"]    = "TD";
                ht["MA_DVCS"]  = Element.sysMa_DvCs;

                //Common.ShowStatus(Languages.GetLanguage("In_Process") + (string)dr["Dien_Giai"]);
                EpointProcessBox.AddMessage(Languages.GetLanguage("In_Process") + (string)dr["Dien_Giai"]);

                SQLExec.Execute("Sp_KetChuyen_Delete", ht, CommandType.StoredProcedure);

                dr["Select"] = false;
            }

            //Common.EndShowStatus();
            //Common.MsgOk(Languages.GetLanguage("End_Process"));
            EpointProcessBox.AddMessage(Languages.GetLanguage("End_Process"));
        }
Пример #3
0
        public override void EpointRelease()
        {
            string strSttPNVC = Tao_PNVC();

            if (strSttPNVC != string.Empty)
            {
                EpointProcessBox.AddMessage("Kết thúc");
            }
        }
Пример #4
0
        public override void EpointRelease()
        {
            try
            {
                string strMsg = string.Empty;
                string strMa_Cbnv, strTen_Cbnv, strEmail, strSubject;


                //string strHost = EmailConfig.strHost;
                //string strCredentials = EmailConfig.strCredentials;
                //string strPassclient = EmailConfig.strPassclient;
                //string strFrom = EmailConfig.strFrom;
                //string strCC = EmailConfig.strCC;
                //string strContentEmail = EmailConfig.strContentEmail;



                #region Format mail

                //string strBodyMail = EmailConfig.EmailBobyBirthDay();

                #endregion
                foreach (DataRow drP in dtBirthDayEmployee.Rows)
                {
                    int Numrd = new Random().Next(0, 3);

                    if ((Boolean)drP["Sent_Mail"])
                    {
                        continue;
                    }

                    strMa_Cbnv  = drP["Ma_Cbnv"].ToString();
                    strTen_Cbnv = drP["Ten_Cbnv"].ToString();


                    EpointProcessBox.AddMessage("Đang gửi " + strMa_Cbnv + " - " + strTen_Cbnv);

                    EmailConfig.EMAIL_CONTENT = "EMAIL_CONTENT" + Numrd.ToString();
                    //EmailConfig.strContentEmail =
                    EmailConfig.SendMailBirthday(string.Empty, drP);
                    System.Threading.Thread.Sleep(20000);
                    // Lưu lại thông tin gửi mail
                    //EmailConfig.SaveInfoSendMail(strMa_Cbnv, (DateTime)drP["Ngay_Sinh"]);

                    EpointProcessBox.AddMessage(strMsg);
                }

                EpointProcessBox.AddMessage("Kết thúc ! ");
                EpointProcessBox.ShowOK(true);
            }
            catch (Exception ex)
            {
                EpointProcessBox.AddMessage(ex.ToString());
                EpointProcessBox.ShowOK(true);
            }
        }
Пример #5
0
        private void UpdateFollower()
        {
            string    strMa_Cbnv, strZalo_ID;
            DataTable dtEm = SQLExec.ExecuteReturnDt("TUANVIET_OFFICIAL.dbo.Z_GetAllEmployee");

            foreach (DataRow drP in dtEm.Rows)
            {
                //if ((Boolean)drP["Sent_Mail"])
                //    continue;

                strMa_Cbnv = drP["Ma_Cbnv"].ToString();
                strZalo_ID = drP["Zalo_ID"].ToString();
                JObject jInfo    = client.getProfileOfFollower(strZalo_ID);
                dynamic dynjInfo = JsonConvert.DeserializeObject(jInfo.ToString());
                if (dynjInfo.error != "0")
                {
                    continue;
                }

                Follower User = new Follower();
                User.id          = dynjInfo.data.user_id;
                User.gender      = dynjInfo.data.user_gender;
                User.name        = dynjInfo.data.display_name;
                User.shared_info = false;
                User.Addr        = dynjInfo.data.user_id_by_app;
                User.Avatar      = dynjInfo.data.avatar;
                if (dynjInfo.data.shared_info != null)//User có chia sẻ thông tin
                {
                    User.Addr        = dynjInfo.data.shared_info.address + "#" + dynjInfo.data.shared_info.ward + "#" + dynjInfo.data.shared_info.district + "#" + dynjInfo.data.shared_info.city;
                    User.Phone       = dynjInfo.data.shared_info.phone;
                    User.name        = dynjInfo.data.shared_info.name;
                    User.shared_info = true;
                    if (dynjInfo.data.shared_info.birth_date != "0")// Có ngày sinh nhật
                    {
                        User.birthday = dynjInfo.data.shared_info.birth_date;
                    }
                }
                if (dynjInfo.data.tags_and_notes_info.tag_names != null)//User có chia sẻ thông tin
                {
                    //User.TagName = dynjInfo.data.tags_and_notes_info.tag_names;
                    JArray items  = (JArray)dynjInfo.data.tags_and_notes_info["tag_names"];
                    int    length = items.Count;
                    for (int i = 0; i < items.Count; i++)
                    {
                        string tag = items[i].ToString();
                        User.TagName += tag + ";";
                        //do something with item
                    }
                }

                SaveZaloResource.SQLUpdateFollowerInfor(User);
            }

            EpointProcessBox.AddMessage("Số lượng người được cập nhật : " + dtEm.Rows.Count.ToString());
        }
Пример #6
0
 public override void EpointRelease()
 {
     if (dtImport == null || dtImport.Rows.Count == 0)
     {
         EpointProcessBox.AddMessage("Không có dữ liệu import");
     }
     else
     {
         Save_OM_Detail(dtImport);
     }
     EpointProcessBox.AddMessage("End");
 }
Пример #7
0
        public override void EpointRelease()
        {
            string   strMa_Vt    = txtMa_Vt.Text.Trim();
            string   strMa_Kho   = txtMa_Kho.Text.Trim();
            DateTime dteNgay_Ct1 = Library.StrToDate(this.txtNgay_Ct1.Text);
            DateTime dteNgay_Ct2 = Library.StrToDate(this.txtNgay_Ct2.Text);

            if (Common.GetPartitionCurrent() != 0 && Common.GetPartitionCurrent() != dteNgay_Ct1.Year && Common.GetPartitionCurrent() != dteNgay_Ct2.Year)
            {
                //Common.MsgCancel("Phải chuyển về phân vùng dữ liệu " + dteNgay_Ct1.Year.ToString() + "!");
                EpointProcessBox.AddMessage("Phải chuyển về phân vùng dữ liệu " + dteNgay_Ct1.Year.ToString() + "!");
                return;
            }

            if (!Common.CheckDataLocked(dteNgay_Ct1) || !Common.CheckDataLocked(dteNgay_Ct2))
            {
                EpointProcessBox.AddMessage(EpointMessage.GetMessage("DATALOCK"));
                //Common.MsgCancel("Dữ liệu đã khóa, liên hệ với nhà quản trị!");
                return;
            }

            string[] strArrParaName  = new string[] { "@Ngay_Ct1", "@Ngay_Ct2", "@Ma_Vt", "@Ma_Kho", "@Ma_DvCs" };
            object[] objArrParaValue = new object[] { dteNgay_Ct1, dteNgay_Ct2, strMa_Vt, strMa_Kho, Element.sysMa_DvCs };

            //Common.ShowStatus(Languages.GetLanguage("In_Process"));
            EpointProcessBox.AddMessage(Languages.GetLanguage("In_Process"));
            lock (this)
            {
                if (rdbGiaBQTH.Checked)
                {
                    SQLExec.Execute("sp_GiaBQTH", strArrParaName, objArrParaValue, CommandType.StoredProcedure);
                }
                else if (rdbGiaBQTT.Checked)
                {
                    SQLExec.Execute("sp_GiaBQTT", strArrParaName, objArrParaValue, CommandType.StoredProcedure);
                }
                else if (rdbGiaNTXT.Checked)
                {
                    return;
                }
            }

            Element.sysNgay_Ct1 = Library.StrToDate(this.txtNgay_Ct1.Text);
            Element.sysNgay_Ct2 = Library.StrToDate(this.txtNgay_Ct2.Text);

            EpointProcessBox.AddMessage(Languages.GetLanguage("End_Process"));
            //Common.EndShowStatus();
        }
Пример #8
0
        public virtual void Import_Excel(DataTable dt)
        {
            OpenFileDialog ofdlg = new OpenFileDialog();

            ofdlg.Filter           = "xls files (*.xls;*.xlsx)|*.xls;*.xlsx";
            ofdlg.RestoreDirectory = true;


            if (ofdlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            DataTable dtImport    = Common.ReadExcel(ofdlg.FileName);
            string    strMsg      = (Element.sysLanguage == enuLanguageType.Vietnamese ? "Bạn có muốn ghi đè lên mẫu tin đã tồn tại không ?" : "Do you want to override exists data ?");
            bool      bIs_Overide = Common.MsgYes_No(strMsg);

            SaveData(dtImport, null, bIs_Overide);

            System.Data.SqlClient.SqlCommand command = SQLExec.GetNewSQLConnection().CreateCommand();
            command.CommandText = "AR_Import_GIABAN";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@UserId", Element.sysUser_Id);
            command.Parameters.AddWithValue("@Ma_DvCs", Element.sysMa_DvCs);
            SqlParameter parameter = new SqlParameter
            {
                SqlDbType     = SqlDbType.Structured,
                ParameterName = "@ARGIABAN",
                TypeName      = "TVP_ARGIABAN",
                Value         = dtImport
            };

            command.Parameters.Add(parameter);
            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception exception)
            {
                command.CommandText = "WHILE @@TRANCOUNT > 0 ROLLBACK TRANSACTION";
                command.CommandType = CommandType.Text;
                command.Parameters.Clear();
                command.ExecuteNonQuery();
                EpointProcessBox.AddMessage("Có lỗi xảy ra :" + exception.Message);
            }
        }
Пример #9
0
 public override void EpointRelease()
 {
     if ((string)Parameters.GetParaValue("TAO_PTT") == "C")
     {
         //string strSttPT = Tao_Pt_TheoKH();
         Save_HanTt0_TaoPTTheoKH();
     }
     else
     {
         string strSttPT = Tao_Pt();
         if (strSttPT != string.Empty)
         {
             Save_HanTt0(strSttPT);
         }
     }
     EpointProcessBox.AddMessage("Kết thúc");
 }
Пример #10
0
        public virtual void Import_Excel(bool CheckAPI)
        {
            //string strMsg = (Element.sysLanguage == enuLanguageType.Vietnamese ? "Bạn có muốn ghi đè lên mẫu tin đã tồn tại không ?" : "Do you want to override exists data ?");
            bool Is_Avail = true;

            if (true)
            {
                SqlCommand command = SQLExec.GetNewSQLConnection().CreateCommand();
                command.CommandText = "Sp_IF_KPICampaign";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@UserId", Element.sysUser_Id);
                command.Parameters.AddWithValue("@Is_OverWrite", chkIsOverride.Checked);
                SqlParameter parameter = new SqlParameter
                {
                    SqlDbType     = SqlDbType.Structured,
                    ParameterName = "@KPICAMPAIGN",
                    TypeName      = "TVP_KPICAMPAIGN",
                    Value         = dtImport
                };
                command.Parameters.Add(parameter);
                try
                {
                    command.ExecuteNonQuery();
                }
                catch (Exception exception)
                {
                    Is_Avail            = false;
                    command.CommandText = "WHILE @@TRANCOUNT > 0 ROLLBACK TRANSACTION";
                    command.CommandType = CommandType.Text;
                    command.Parameters.Clear();
                    command.ExecuteNonQuery();
                    EpointProcessBox.AddMessage("Có lỗi xảy ra :" + exception.Message);
                }
            }
            //return;
            if (!Is_Avail)
            {
                return;
            }

            EpointProcessBox.AddMessage("Kết thúc");
        }
Пример #11
0
        public virtual void Import_Excel(bool CheckAPI)
        {
            //string strMsg = (Element.sysLanguage == enuLanguageType.Vietnamese ? "Bạn có muốn ghi đè lên mẫu tin đã tồn tại không ?" : "Do you want to override exists data ?");
            bool bIsImport = DataTool.SQLCheckExist("sys.procedures", "Name", "OM_Import_PJP");

            if (bIsImport)
            {
                SqlCommand command = SQLExec.GetNewSQLConnection().CreateCommand();
                command.CommandText = "OM_Import_PJP";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Ma_DvCs", Element.sysMa_DvCs);
                command.Parameters.AddWithValue("@UserId", Element.sysUser_Id);
                command.Parameters.AddWithValue("@IsDelete", chkIs_Delete.Checked);
                SqlParameter parameter = new SqlParameter
                {
                    SqlDbType     = SqlDbType.Structured,
                    ParameterName = "@TablePJP",
                    TypeName      = "TVP_OMPJP",
                    Value         = dtImport
                };
                command.Parameters.Add(parameter);
                try
                {
                    command.ExecuteNonQuery();
                }
                catch (Exception exception)
                {
                    command.CommandText = "WHILE @@TRANCOUNT > 0 ROLLBACK TRANSACTION";
                    command.CommandType = CommandType.Text;
                    command.Parameters.Clear();
                    command.ExecuteNonQuery();
                    EpointProcessBox.AddMessage("Có lỗi xảy ra :" + exception.Message);
                }
            }

            EpointProcessBox.AddMessage("Kết thúc");
        }
Пример #12
0
        void Send()
        {
            if (!System.IO.Directory.Exists(txtSendPath.Text.Trim()))
            {
                return;
            }

            if (dteNgay_Send1.Text.Replace(" ", "") == "//" || dteNgay_Send2.Text.Replace(" ", "") == "//")
            {
                return;
            }

            if (Library.StrToDate(dteNgay_Send1.Text) > Library.StrToDate(dteNgay_Send2.Text))
            {
                return;
            }

            Common.ShowStatus(Languages.GetLanguage("In_Process"));
            //EpointProcessBox.Show();
            //EpointProcessBox.SetStatus(Languages.GetLanguage("In_Process"));
            //EpointProcessBox.AddMessage(Languages.GetLanguage("In_Process"));

            string strFileName   = FileNameValid;
            string strSourcePath = Environment.GetFolderPath(Environment.SpecialFolder.Templates) + "\\" + strFileName;
            string strTableList  = string.Empty;

            if (!System.IO.Directory.Exists(strSourcePath))
            {
                System.IO.Directory.CreateDirectory(strSourcePath);
            }

            foreach (DataRow dr in dtTranferData.Rows)
            {
                if (!(bool)dr["Is_Send"])
                {
                    continue;
                }

                string strTable_Name  = (string)dr["Table_Name"];
                string strTable_Name0 = DataTool.SQLGetNameByCode("SYSDmTable", "Table_Name", "Table_Name0", strTable_Name);
                string strData_Type   = (string)dr["Data_Type"];
                string strFilter_Key  = (string)dr["Filter_Key"];

                if (strTable_Name0 == string.Empty)
                {
                    EpointProcessBox.AddMessage("Không tồn tại bảng " + strTable_Name + " trong DmTable!");
                    //EpointMessage.MsgCancel("Không tồn tại bảng " + strTable_Name + " trong DmTable!");
                    continue;
                }

                string strSQLExec = "SELECT * FROM " + strTable_Name0;
                strTableList += "," + strTable_Name;

                //Điều kiện lọc cứng: Ngay_Ct, Ma_DvCs
                Hashtable htPara = new Hashtable();
                if (strData_Type == "1")                              //Chứng từ
                {
                    if (Common.InlistLike(strTable_Name0, "R06CTTS")) //Nếu là bảng CTTS
                    {
                        strSQLExec += " WHERE ((Ma_Dvcs = @Ma_Data) OR (Ma_Dvcs = @Ma_Data1))";
                    }
                    else
                    {
                        strSQLExec += " WHERE (Ngay_Ct BETWEEN @Ngay_Ct1 AND @Ngay_Ct2) AND (Ma_DvCs = @Ma_DvCs)";
                    }
                    htPara.Add("NGAY_CT1", dteNgay_Send1.Text);
                    htPara.Add("NGAY_CT2", dteNgay_Send2.Text);
                    htPara.Add("MA_DVCS", Element.sysMa_DvCs);
                }
                else if (strData_Type == "2")                         //Danh mục
                {
                    if (Common.InlistLike(strTable_Name0, "R06CTTS")) //Nếu là bảng CTTS
                    {
                        strSQLExec += " WHERE ((Ma_Dvcs = @Ma_Data) OR (Ma_Dvcs = @Ma_Data1))";
                    }
                    else
                    {
                        strSQLExec += " WHERE ((Ma_Data = @Ma_Data) OR (Ma_Data = @Ma_Data1))";
                    }
                    htPara.Add("MA_DATA", Element.sysMa_Data);
                    htPara.Add("MA_DATA1", "*");
                }
                else if (strData_Type == "3") //hùng thêm Tài sản cố dịnh
                {
                    strSQLExec += " WHERE (Ngay_Ps BETWEEN @Ngay_Ct1 AND @Ngay_Ct2) AND (Ma_DvCs = @Ma_DvCs)";
                    htPara.Add("NGAY_CT1", dteNgay_Send1.Text);
                    htPara.Add("NGAY_CT2", dteNgay_Send2.Text);
                    htPara.Add("MA_DVCS", Element.sysMa_DvCs);
                }
                else
                {
                    strSQLExec += " WHERE (1 = 1)";
                }

                //Điều kiện lọc mềm
                if (strFilter_Key != string.Empty)
                {
                    strSQLExec += " AND (" + strFilter_Key + ")";
                }

                DataTable dtSend = SQLExec.ExecuteReturnDt(strSQLExec, htPara, CommandType.Text);

                FileStream fs = new FileStream(strSourcePath + "\\" + strTable_Name + ".dat", FileMode.Create);
                new BinaryFormatter().Serialize(fs, dtSend);
                fs.Close();
            }

            //DataInfo
            System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
            xml.LoadXml(
                "<?xml version='1.0' encoding='utf-8' ?>" +
                "<DataInfo>" +
                "<Member_ID>" + Element.sysUser_Id + "</Member_ID>" +
                "<Ngay_Ct1>" + dteNgay_Send1.Text + "</Ngay_Ct1>" +
                "<Ngay_Ct2>" + dteNgay_Send2.Text + "</Ngay_Ct2>" +
                "<Ma_DvCs>" + Element.sysMa_DvCs + "</Ma_DvCs>" +
                "<Ma_Data>" + Element.sysMa_Data + "</Ma_Data>" +
                "<TableList>" + strTableList + "</TableList>" +
                "</DataInfo>");

            xml.Save(strSourcePath + "\\info.xml");

            string strfilename;

            if (chkSendOnline.Checked) //Truyền thằng vào CSDL
            {
                Common.ZipFile(strSourcePath, Environment.GetFolderPath(Environment.SpecialFolder.Templates));
                System.IO.Directory.Delete(strSourcePath, true);
                strfilename = strSourcePath + ".ros";
            }
            else
            {
                Common.ZipFile(strSourcePath, txtSendPath.Text);
                System.IO.Directory.Delete(strSourcePath, true);
                strfilename = strSourcePath + ".ros";
            }

            if (chkSendOnline.Checked && File.Exists(strfilename)) //Truyền thẳng vào CSDL
            {
                SqlCommand sqlcom = new SqlCommand();
                sqlcom.Connection = this.GetTranferConnection(false);
                sqlcom.Parameters.Clear();

                FileInfo fileInfo = new FileInfo(strfilename);
                if (fileInfo.Length < 2147483647) //2147483647 - is the max size of the data 1.9gb
                {
                    byte[] _fileData = File.ReadAllBytes(strfilename);

                    sqlcom.Parameters.AddWithValue("FILE_ID", strFileName);
                    sqlcom.Parameters.AddWithValue("FILE_CONTENT", _fileData);
                    sqlcom.Parameters.AddWithValue("NGAY_CT1", Library.StrToDate(this.dteNgay_Send1.Text));
                    sqlcom.Parameters.AddWithValue("NGAY_CT2", Library.StrToDate(this.dteNgay_Send2.Text));
                    sqlcom.Parameters.AddWithValue("MA_DVCS", Element.sysMa_DvCs);
                    sqlcom.Parameters.AddWithValue("MA_DATA", Element.sysMa_Data);
                    sqlcom.Parameters.AddWithValue("MEMBER_ID", Element.sysUser_Id);
                    sqlcom.Parameters.AddWithValue("TABLELIST", strTableList);

                    string strsql = @"INSERT INTO SYSTranferDataStore (File_ID, File_Content, Ngay_Ct1, Ngay_Ct2, Ma_DvCs, Ma_Data, Member_ID, TableList) 
								VALUES (@File_Id, @File_Content, @Ngay_Ct1, @Ngay_Ct2, @Ma_DvCs, @Ma_Data, @Member_ID, @TableList)"                                ;

                    sqlcom.CommandText = strsql;

                    try
                    {
                        sqlcom.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        //EpointProcessBox.AddMessage("Không truyền đc dữ liệu, error: " + ex.Message);
                        EpointMessage.MsgCancel("Không truyền đc dữ liệu, error: " + ex.Message);
                        return;
                    }
                }
                else
                {
                    //EpointProcessBox.AddMessage("Dung lượng file quá lớn");
                    EpointMessage.MsgOk("Dung lượng file quá lớn");
                }
            }

            Common.SetBufferValue("SendOnline", chkSendOnline.Checked ? "1" : "0");
            Element.sysNgay_Ct1 = Library.StrToDate(this.dteNgay_Send1.Text);
            Element.sysNgay_Ct2 = Library.StrToDate(this.dteNgay_Send2.Text);

            //EpointMessage.MsgOk(Languages.GetLanguage("End_Process"));
            //EpointProcessBox.AddMessage(Languages.GetLanguage("End_Process"));
            //EpointProcessBox.ShowOK(true);
            Common.EndShowStatus();
        }
Пример #13
0
        public override void EpointRelease()
        {
            string strDBSource = Element.sysDatabaseName.ToString();
            string strDBDest   = Parameters.GetParaValue("DATABASE_DEST").ToString();

            DateTime dteNgay_Ct1   = Library.StrToDate(this.txtNgay_Ct1.Text);
            DateTime dteNgay_Ct2   = Library.StrToDate(this.txtNgay_Ct2.Text);
            string   strMa_Ct_List = txtMa_Ct.Text;

            if (!Common.CheckDataLocked(dteNgay_Ct1) || !Common.CheckDataLocked(dteNgay_Ct2))
            {
                EpointProcessBox.AddMessage("Dữ liệu đã khóa, liên hệ với nhà quản trị !");
                return;
            }

            try
            {
                //Common.ShowStatus(Languages.GetLanguage("In_Process"));

                Hashtable ht = new Hashtable();
                ht["DBSOURCE"] = strDBSource;
                ht["DBDEST"]   = strDBDest;
                ht["MA_DVCS"]  = Element.sysMa_DvCs.ToString();
                if (tabControl1.SelectedTab == tabPageTranVoucher)
                {
                    EpointProcessBox.AddMessage("Đang chuyển số liệu chứng từ ");
                    if (dtTranVoucher == null)
                    {
                        return;
                    }

                    foreach (DataRow dr in dtTranVoucher.Rows)
                    {
                        if ((bool)dr["CHON"])
                        {
                            ht["STT"]   = dr["Stt"].ToString();
                            ht["MA_CT"] = dr["Ma_Ct"].ToString();

                            SQLExec.Execute("sp_Tranfer_Voucher", ht, CommandType.StoredProcedure);
                        }
                    }
                }
                else if (tabControl1.SelectedTab == tabPageTranList)
                {
                    EpointProcessBox.AddMessage("Đang chuyển danh mục ");
                    foreach (DataRow dr in dtTranList.Rows)
                    {
                        if ((bool)dr["IS_SEND"])
                        {
                            EpointProcessBox.AddMessage("Đang chuyển dữ liệu " + dr["Description"].ToString());
                            ht["TABLE_NAME"] = dr["Table_Name"].ToString();
                            SQLExec.Execute("sp_Tranfer_DanhMuc", ht, CommandType.StoredProcedure);
                        }
                    }
                }
                else if (tabControl1.SelectedTab == tabPageKhac)
                {
                    DateTime dteNgay_Ct01 = Library.StrToDate(this.txtNgay_Ct01.Text);
                    DateTime dteNgay_Ct02 = Library.StrToDate(this.txtNgay_Ct02.Text);

                    ht["NGAY_CT1"] = dteNgay_Ct01;
                    ht["NGAY_CT2"] = dteNgay_Ct02;
                    //ht["NAM"] = Element.sysWorkingYear;

                    if (chkDuDau_KeToan.Checked)
                    {
                        EpointProcessBox.AddMessage("Đang chuyển số dư đầu tài khoản ");
                        SQLExec.Execute("sp_Tranfer_DuDau_KeToan", ht, CommandType.StoredProcedure);
                    }
                    if (chkDuDau_TonKho.Checked)
                    {
                        EpointProcessBox.AddMessage("Đang chuyển số dư đầu tồn kho ");
                        SQLExec.Execute("sp_Tranfer_DuDau_TonKho", ht, CommandType.StoredProcedure);
                    }
                    if (chkTaiSan.Checked)
                    {
                        EpointProcessBox.AddMessage("Đang chuyển chứng từ tài sản ");
                        SQLExec.Execute("sp_Tranfer_TaiSan", ht, CommandType.StoredProcedure);
                    }
                }

                Element.sysNgay_Ct1 = Library.StrToDate(this.txtNgay_Ct1.Text);
                Element.sysNgay_Ct2 = Library.StrToDate(this.txtNgay_Ct2.Text);
                EpointProcessBox.AddMessage(Languages.GetLanguage("End_Process"));
            }
            catch (Exception)
            {
                EpointProcessBox.AddMessage("Không tìm thấy Database cần chuyển đến !");
            }
        }
Пример #14
0
        void btImport_Click(object sender, EventArgs e)
        {
            OptionProcess = "KPIRANK";

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "xls files (*.xls;*.xlsx)|*.xls;*.xlsx";
            ofd.RestoreDirectory = true;

            if (Common.GetBufferValue("ImportExcelPathHRM") != string.Empty)
            {
                ofd.InitialDirectory = Common.GetBufferValue("ImportExcelPathHRM");
            }
            else
            {
                ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            }

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Common.SetBufferValue("ImportExcelPathHRM", System.IO.Path.GetDirectoryName(ofd.FileName));
                    strFileName = ofd.FileName;
                }
                catch { }


                try
                {
                    DataTable dtStruct = new DataTable();
                    dtStruct = SQLExec.ExecuteReturnDt("DECLARE @TVP_Table AS TVP_HRSALARYRANK SELECT * FROM @TVP_Table");

                    dtImport = Common.ReadExcel(strFileName);
                    foreach (DataRow dr in dtImport.Rows)
                    {
                        DataRow drStruct = dtStruct.NewRow();
                        Common.CopyDataRow(dr, drStruct);
                        dtStruct.Rows.Add(drStruct);
                    }

                    if (dtStruct != null)
                    {
                        SqlCommand command = SQLExec.GetNewSQLConnection().CreateCommand();
                        command.CommandText = "Sp_IF_HRSALARYRANK";
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@TableName", "HRSalaryRank");
                        command.Parameters.AddWithValue("@UserId", Element.sysUser_Id);
                        SqlParameter parameter = new SqlParameter
                        {
                            SqlDbType     = SqlDbType.Structured,
                            ParameterName = "@TVP_Table",
                            TypeName      = "TVP_HRSALARYRANK",
                            Value         = dtStruct
                        };
                        command.Parameters.Add(parameter);
                        try
                        {
                            command.ExecuteNonQuery();
                        }
                        catch (Exception exception)
                        {
                            command.CommandText = "WHILE @@TRANCOUNT > 0 ROLLBACK TRANSACTION";
                            command.CommandType = CommandType.Text;
                            command.Parameters.Clear();
                            command.ExecuteNonQuery();
                            EpointProcessBox.AddMessage("Có lỗi xảy ra :" + exception.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Không mở được bảng dữ liệu " + strFileName + "Error :" + ex.Message);
                }
            }
        }
Пример #15
0
        private string Tao_Pt_TheoKH()
        {
            int    Stt0          = 0;
            string strSo_Ct      = string.Empty;
            string strSo_Ct_New  = string.Empty;
            string strCreate_Log = string.Empty;

            string iStt = string.Empty;

            try
            {
                foreach (DataRow drhd in dtCtHanTt.Rows)
                {
                    DataRow drDt = DataTool.SQLGetDataRowByID("LIDOITUONG", "Ma_Dt", drhd["Ma_Dt"].ToString());

                    if (drDt != null)
                    {
                        string strQueryPh   = string.Empty;
                        string strQueryCthd = string.Empty;

                        if ((bool)drhd["Thanh_Toan"])
                        {
                            #region GetNew_SoCt


                            DataRow  drDmct        = DataTool.SQLGetDataRowByID("SYSDMCT", "Ma_Ct", "PTT");
                            DataRow  dr            = SQLExec.ExecuteReturnDt("SELECT Ma_DvCs FROM SYSDMDVCS WHERE Ma_DvCs = '" + Element.sysMa_DvCs + "' ").Rows[0];
                            DateTime dteNgay_Ct_tt = Library.StrToDate(dteNgay_Ct_TT.Text);
                            string   strSQLExec    = "SELECT So_Ct FROM GLVOUCHER  (NOLOCK) WHERE Ma_DvCs = '" + Element.sysMa_DvCs
                                                     + "' AND Ma_Ct = 'PTT' AND MONTH(Ngay_Ct) =" + dteNgay_Ct_tt.Month.ToString()
                                                     + " AND YEAR(Ngay_Ct) =" + dteNgay_Ct_tt.Year.ToString() + " AND So_Ct <> '' ";
                            //+ " AND DAY(Ngay_Ct) =" + dteNgay_Ct1.Day.ToString()

                            DataTable dt = SQLExec.ExecuteReturnDt(strSQLExec);
                            if (dt.Rows.Count > 0)
                            {
                                string strSQL = "SELECT ISNULL(MAX(So_Ct),'') FROM GLVOUCHER  (NOLOCK) WHERE Ma_DvCs = '" + Element.sysMa_DvCs + "' AND Ma_Ct = 'PTT' AND MONTH(Ngay_Ct) =" + dteNgay_Ct_tt.Month.ToString() + " AND YEAR(Ngay_Ct) =" + dteNgay_Ct_tt.Year.ToString() + "";
                                strSo_Ct = SQLExec.ExecuteReturnValue(strSQL).ToString();
                                Hashtable htPara = new Hashtable();
                                htPara.Add("TABLENAME", "GLVOUCHER");
                                htPara.Add("COLUMNNAME", "So_Ct");
                                htPara.Add("CURRENTID", strSo_Ct);
                                htPara.Add("KEY", "Ma_DvCs = '" + Element.sysMa_DvCs + "' AND Ma_Ct = 'PTT' AND MONTH(Ngay_Ct) = " + dteNgay_Ct_tt.Month + " AND YEAR(Ngay_Ct) = " + dteNgay_Ct_tt.Year + "");
                                htPara.Add("PREFIXLEN", Convert.ToInt32(drDmct["PrefixLen"]));
                                htPara.Add("SUFFIXLEN", Convert.ToInt32(drDmct["SubfixLen"]));

                                strSo_Ct_New = (string)SQLExec.ExecuteReturnValue("sp_GetNewID", htPara, CommandType.StoredProcedure);
                                //strSo_Ct_New = drDmct["Prefix"].ToString() + dteNgay_Ct_tt.Month.ToString("00") + dteNgay_Ct_tt.Day.ToString("00") + strSo_Ct_New.Substring(strSo_Ct_New.Length - 4, 4);
                            }
                            else
                            {
                                strSo_Ct_New = drDmct["Prefix"].ToString() + dteNgay_Ct_tt.Month.ToString("00") + dteNgay_Ct_tt.Day.ToString("00") + "0001";
                            }


                            #endregion

                            strCreate_Log = Common.GetCurrent_Log();



                            bool bSttValid = false;

                            while (!bSttValid)
                            {
                                iStt = Common.GetNewStt("01", true);
                                string    strPH  = @"SELECT * FROM GLVOUCHER  (NOLOCK) WHERE Stt= '" + iStt + "'";
                                DataTable dtCtph = SQLExec.ExecuteReturnDt(strPH);
                                if (dtCtph.Rows.Count > 0)
                                {
                                    bSttValid = false;
                                }
                                else
                                {
                                    bSttValid = true;
                                }
                            }
                            #region Tạo Phiếu thu
                            double dbTien3 = 0;

                            // Tạo header

                            strQueryPh += @"
                                    INSERT INTO	GLVOUCHER (Stt, Ma_Ct, Ngay_Ct, So_Ct, Ma_Dt, Dien_giai, TTien0, TTien_Nt0, TTien3, TTien_Nt3, Create_Log, Ct_Di_Kem,Is_ThanhToan, Ma_Dvcs)
                                        VALUES('"                         + iStt + "', 'PTT', '" + Library.DateToStr(dteNgay_Ct_tt) + "', '" + strSo_Ct_New + "', '"
                                          + drhd["Ma_Dt"] + "', N'" + txtDien_Giai.Text + " - Số Ct : " + drhd["So_Ct_Hd"] + "', " + drhd["Tien_Tt1"] + ", " + drhd["Tien_Tt1"] + ", " + dbTien3 + ", " + dbTien3 + ", '"
                                          + strCreate_Log + "', '" + drhd["So_Ct_Hd"] + "',1, '" + Element.sysMa_DvCs + "')";


                            // Tạo Chi tiết
                            Stt0 += 1;


                            strQueryCthd += @"INSERT INTO	CATIEN (Stt, Stt0, Ma_Ct, Ngay_Ct, So_Ct, Dien_Giai, Ong_Ba, Ma_Dt,Dia_Chi,Ten_Dt,
                                                                    Tk_No, Tk_Co, Tien_Nt9, Tien, Tien_Nt, 
                                                                    Ma_Thue, Thue_GtGt, Tien3, Tien_Nt3, Tk_No3, Tk_Co3, Ngay_Ct0, So_Ct0, So_Seri0, Ma_So_Thue, Ten_DtGtGt,
                                                                    Ma_Dvcs, Ma_Tte, Ty_Gia)
                                                    VALUES('"                             + iStt + "', '" + Stt0 + "', 'PTT', '" + dteNgay_Ct_TT.Text + "','" + strSo_Ct_New + "', N'"
                                            + txtDien_Giai.Text + " - Số Ct : " + drhd["So_Ct_Hd"]
                                            + "',  N'" + drDt["Ong_Ba"] + "', '" + drhd["Ma_Dt"] + "',N'" + drDt["Dia_Chi"] + "',  N'" + drDt["Ten_Dt"] + "','"
                                            + txtTk_Tt.Text + "','" + drhd["Tk"] + "', " + drhd["Tien_Tt1"] + ",  " + drhd["Tien_Tt1"] + ",  " + drhd["Tien_Tt1"]
                                            + ", '', 0, 0, 0, '', '', '', '', '', '', N'', '" + Element.sysMa_DvCs + "','VND', 1)\n";


                            if (numTTien_Tt.Value > 0)
                            {
                                SQLExec.Execute(strQueryPh);
                                SQLExec.Execute(strQueryCthd);

                                //Common.MsgOk("Chứng từ đã tạo xong Số chứng từ : " + strSo_Ct_New);
                                this.strStt_Pt    = iStt;
                                this.strSo_Ct_New = strSo_Ct_New;
                                //return iStt;
                            }
                            #endregion


                            //Tao thanh toán mới
                            DataRow   rowCtThanhtoan;
                            DataRow   row2          = drhd;
                            DataTable dtTableSource = SQLExec.ExecuteReturnDt("SELECT *, CAST(0 AS BIT) AS Thanh_Toan FROM GLTHANHTOANCT WHERE 0 = 1");

                            rowCtThanhtoan = dtTableSource.NewRow();
                            Common.CopyDataRow(row2, rowCtThanhtoan);

                            if ((rowCtThanhtoan["Ngay_Ct_TT"] == DBNull.Value) && (((DateTime)rowCtThanhtoan["Ngay_Ct_TT"]) == Element.sysNgay_Min))
                            {
                                rowCtThanhtoan["Ngay_Ct_TT"] = Library.StrToDate(this.dteNgay_Ct_TT.Text);
                            }
                            rowCtThanhtoan["Stt_PT"]         = iStt;
                            rowCtThanhtoan["Tk"]             = row2["Tk"];
                            rowCtThanhtoan["Ma_Dt"]          = row2["Ma_Dt"];
                            rowCtThanhtoan["Stt_HD"]         = row2["Stt_HD"];
                            rowCtThanhtoan["Tien_Tt"]        = row2["Tien_Tt1"];
                            rowCtThanhtoan["Tien_Tt_Nt"]     = row2["Tien_Tt_Nt1"];
                            rowCtThanhtoan["Tien_CLTG"]      = row2["Tien_CLTG"];
                            rowCtThanhtoan["LastModify_Log"] = row2["LastModify_Log"];
                            dtTableSource.Rows.Add(rowCtThanhtoan);

                            dtTableSource.AcceptChanges();
                            this.Save_HanTt0(iStt, dtTableSource);


                            // tạo thanh toán cũ phục vụ cái chưa update.
                            try
                            {
                                bool a = SQLExec.Execute(@"INSERT INTO GLTHANHTOAN( Stt, Ma_Ct, Ngay_Ct, So_Ct, Dien_Giai, Ma_Tte, Ty_Gia, Tk, Ma_Dt, Tien_Tt, Tien_Tt_Nt, Stt_Hd, Is_SoDuDau, Ma_DvCs, 
			                        Tien_CLTG, Dau_ClTg, Tk_No_ClTg, Tk_Co_ClTg, Tk_No_ClTg2, Tk_Co_ClTg2, LastModify_Log, Is_CLTG, User_Crtd, User_Edit, Ngay_Crtd, Ngay_Edit)

		                            select  Stt = Stt_PT, Ma_Ct = 'PTT', Ngay_Ct  = Ngay_Ct_TT, So_Ct = So_Ct_TT, Dien_Giai = Dien_Giai_TT, Ma_Tte = 'VND', Ty_Gia = 1, Tk , Ma_Dt, Tien_Tt, Tien_Tt_Nt, Stt_Hd, Is_SoDuDau = 0, Ma_DvCs, 
				                        Tien_CLTG, Dau_ClTg, Tk_No_ClTg, Tk_Co_ClTg, Tk_No_ClTg2, Tk_Co_ClTg2, LastModify_Log, Is_CLTG = Dau_ClTg, User_Crtd = '', User_Edit = '', Ngay_Crtd = GETDATE(), Ngay_Edit = GETDATE()
		                            from GLTHANHTOANCT
		                            WHERE Stt_Pt = '"         + iStt + "'");
                            }
                            catch (Exception e1)
                            {
                                EpointProcessBox.AddMessage(e1.ToString());
                            }



                            EpointProcessBox.AddMessage("Thanh toán công nợ khách hàng " + drhd["Ma_Dt"].ToString() + " Số Ct : " + strSo_Ct_New);
                        }
                    }
                }
                return(string.Empty);
            }
            catch (Exception ex)
            {
                Common.MsgOk(ex.ToString());
                return(string.Empty);
                // throw;
            }
        }
Пример #16
0
        private string Tao_Pt()
        {
            int    Stt0          = 0;
            string strSo_Ct      = string.Empty;
            string strSo_Ct_New  = string.Empty;
            string strCreate_Log = string.Empty;
            string strCt_Di_Kem  = string.Empty;
            string strQueryPh    = string.Empty;
            string strQueryCthd  = string.Empty;
            string iStt          = string.Empty;

            try
            {
                #region GetNew_SoCt


                DataRow  drDmct        = DataTool.SQLGetDataRowByID("SYSDMCT", "Ma_Ct", "PTT");
                DataRow  dr            = SQLExec.ExecuteReturnDt("SELECT Ma_DvCs FROM SYSDMDVCS WHERE Ma_DvCs = '" + Element.sysMa_DvCs + "' ").Rows[0];
                DateTime dteNgay_Ct_tt = Library.StrToDate(dteNgay_Ct_TT.Text);
                string   strSQLExec    = "SELECT So_Ct FROM GLVOUCHER  (NOLOCK) WHERE Ma_DvCs = '" + Element.sysMa_DvCs
                                         + "' AND Ma_Ct = 'PTT' AND MONTH(Ngay_Ct) =" + dteNgay_Ct_tt.Month.ToString()
                                         + " AND Ngay_Ct ='" + Library.DateToStr(dteNgay_Ct_tt) + "' AND So_Ct <> '' ";
                //+ " AND DAY(Ngay_Ct) =" + dteNgay_Ct1.Day.ToString()

                DataTable dt = SQLExec.ExecuteReturnDt(strSQLExec);
                if (dt.Rows.Count > 0)
                {
                    string strSQL = "SELECT ISNULL(MAX(So_Ct),'') FROM GLVOUCHER  (NOLOCK) WHERE Ma_DvCs = '" + Element.sysMa_DvCs + "' AND Ma_Ct = 'PTT' AND MONTH(Ngay_Ct) =" + dteNgay_Ct_tt.Month.ToString() + " AND YEAR(Ngay_Ct) =" + dteNgay_Ct_tt.Year.ToString() + "";
                    strSo_Ct = SQLExec.ExecuteReturnValue(strSQL).ToString();
                    Hashtable htPara = new Hashtable();
                    htPara.Add("TABLENAME", "GLVOUCHER");
                    htPara.Add("COLUMNNAME", "So_Ct");
                    htPara.Add("CURRENTID", strSo_Ct);
                    htPara.Add("KEY", "Ma_DvCs = '" + Element.sysMa_DvCs + "' AND Ma_Ct = 'PTT' AND Ngay_Ct ='" + Library.DateToStr(dteNgay_Ct_tt) + "' AND YEAR(Ngay_Ct) = " + dteNgay_Ct_tt.Year + "");
                    htPara.Add("PREFIXLEN", Convert.ToInt32(drDmct["PrefixLen"]));
                    htPara.Add("SUFFIXLEN", Convert.ToInt32(drDmct["SubfixLen"]));

                    strSo_Ct_New = (string)SQLExec.ExecuteReturnValue("sp_GetNewID", htPara, CommandType.StoredProcedure);
                    //strSo_Ct_New = drDmct["Prefix"].ToString() + dteNgay_Ct_tt.Month.ToString("00") + dteNgay_Ct_tt.Day.ToString("00") + strSo_Ct_New.Substring(strSo_Ct_New.Length - 4, 4);
                }
                else
                {
                    strSo_Ct_New = "PTT" + dteNgay_Ct_tt.Month.ToString("00") + dteNgay_Ct_tt.Day.ToString("00") + "0001";
                }


                #endregion

                strCreate_Log = Common.GetCurrent_Log();



                bool bSttValid = false;

                while (!bSttValid)
                {
                    iStt = Common.GetNewStt("01", true);
                    string    strPH  = @"SELECT * FROM GLVOUCHER   (NOLOCK) WHERE Stt= '" + iStt + "'";
                    DataTable dtCtph = SQLExec.ExecuteReturnDt(strPH);
                    if (dtCtph.Rows.Count > 0)
                    {
                        bSttValid = false;
                    }
                    else
                    {
                        bSttValid = true;
                    }
                }

                double dbTien0 = Convert.ToDouble(numTTien_Tt.Value);
                double dbTien3 = 0;
                //double dbTTien = dbTien0 + dbTien3;
                double dbThue = 0;



                foreach (DataRow drhd in dtCtHanTt.Rows)
                {
                    if ((bool)drhd["Thanh_Toan"])
                    {
                        Stt0 += 1;
                        DataRow drDt = DataTool.SQLGetDataRowByID("LIDOITUONG", "Ma_Dt", drhd["Ma_Dt"].ToString());

                        strQueryCthd += @"INSERT INTO	CATIEN (Stt, Stt0, Ma_Ct, Ngay_Ct, So_Ct, Dien_Giai, Ong_Ba, Ma_Dt,Ten_DtGtGt,Ma_Cbnv,Ma_Cbnv_Gh,Dia_Chi,
                                                                    Tk_No, Tk_Co, Tien_Nt9, Tien, Tien_Nt, 
                                                                    Ma_Thue, Thue_GtGt, Tien3, Tien_Nt3, Tk_No3, Tk_Co3, Ngay_Ct0, So_Ct0, So_Seri0, Ma_So_Thue, 
                                                                    Ma_Dvcs, Ma_Tte, Ty_Gia)"
                                        + @" VALUES('" + iStt + "', '" + Stt0 + "', 'PTT', '" + dteNgay_Ct_TT.Text + "','" + strSo_Ct_New + "', N'"
                                        + txtDien_Giai.Text + " - Số Ct : " + drhd["So_Ct_Hd"]
                                        + "',  N'" + drDt["Ong_Ba"] + "', '" + drhd["Ma_Dt"] + "',N'" + drhd["So_Ct_Hd"] + "','" + drhd["MA_CBNV_Bh"] + "','" + drhd["MA_CBNV_GH"] + "',N'" + drDt["Dia_Chi"] + "','"
                                        + txtTk_Tt.Text + "','" + drhd["Tk"] + "', " + drhd["Tien_Tt1"] + ",  " + drhd["Tien_Tt1"] + ",  " + drhd["Tien_Tt1"]
                                        + ", '', 0, 0, 0, '', '', '', '', '', '', '"
                                        + Element.sysMa_DvCs + "','VND', 1)\n";

                        //strCt_Di_Kem += drhd["So_Ct_Hd"].ToString() + ",";
                    }
                }

                strQueryPh = @"
                                    INSERT INTO	GLVOUCHER (Stt, Ma_Ct, Ngay_Ct, So_Ct, Ma_Dt, Dien_giai, TTien0, TTien_Nt0, TTien3, TTien_Nt3, Create_Log, Ct_Di_Kem,Is_ThanhToan,Ma_Nvu, Ma_Dvcs)
                                        VALUES('"                         + iStt + "', 'PTT', '" + Library.DateToStr(dteNgay_Ct_tt) + "', '" + strSo_Ct_New + "', '"
                             + txtMa_Dt.Text + "', N'" + txtDien_Giai.Text + "', " + dbTien0 + ", " + dbTien0 + ", " + dbTien3 + ", " + dbTien3 + ", '"
                             + strCreate_Log + "', '" + strCt_Di_Kem + "',1,'PTT', '" + Element.sysMa_DvCs + "')";


                if (numTTien_Tt.Value > 0)
                {
                    if (SQLExec.Execute(strQueryPh) && SQLExec.Execute(strQueryCthd))
                    {
                        EpointProcessBox.AddMessage("Chứng từ đã tạo xong Số chứng từ : " + strSo_Ct_New);
                        this.strStt_Pt    = iStt;
                        this.strSo_Ct_New = strSo_Ct_New;
                        return(iStt);
                    }
                }

                return(string.Empty);;
            }
            catch (Exception ex)
            {
                EpointProcessBox.AddMessage(ex.ToString());
                return(string.Empty);
                // throw;
            }
        }
Пример #17
0
        private void Save_HanTt0_TaoPTTheoKH()
        {
            DataRow rowCtThanhtoan;

            //DataRow CurrRow = ((DataRowView)this.bdsThanhToan.Current).Row;
            //double dbTien_PT = Convert.ToDouble(CurrRow["Tien_PT"]);
            //double dbTien_Pt_Nt = Convert.ToDouble(CurrRow["Tien_PT_Nt"]);

            if (true)
            {
                DataTable dtTableSource = SQLExec.ExecuteReturnDt("SELECT *, CAST(0 AS BIT) AS Thanh_Toan FROM GLTHANHTOANCT WHERE 0 = 1");
                foreach (DataRow row2 in this.dtCtHanTt.Select(this.bdsHanTt.Filter))
                {
                    if (!(bool)row2["Thanh_Toan"])
                    {
                        continue;
                    }
                    rowCtThanhtoan = dtTableSource.NewRow();
                    Common.CopyDataRow(row2, rowCtThanhtoan);

                    if ((rowCtThanhtoan["Ngay_Ct_TT"] == DBNull.Value) && (((DateTime)rowCtThanhtoan["Ngay_Ct_TT"]) == Element.sysNgay_Min))
                    {
                        rowCtThanhtoan["Ngay_Ct_TT"] = Library.StrToDate(this.dteNgay_Ct_TT.Text);
                    }
                    rowCtThanhtoan["Stt_PT"]         = "";
                    rowCtThanhtoan["Tk"]             = row2["Tk"];
                    rowCtThanhtoan["Ma_Dt"]          = row2["Ma_Dt"];
                    rowCtThanhtoan["Stt_HD"]         = row2["Stt_HD"];
                    rowCtThanhtoan["Tien_Tt"]        = row2["Tien_Tt1"];
                    rowCtThanhtoan["Tien_Tt_Nt"]     = row2["Tien_Tt_Nt1"];
                    rowCtThanhtoan["Tien_CLTG"]      = row2["Tien_CLTG"];
                    rowCtThanhtoan["LastModify_Log"] = row2["LastModify_Log"];
                    dtTableSource.Rows.Add(rowCtThanhtoan);
                }
                dtTableSource.AcceptChanges();
                SqlCommand command = SQLExec.GetNewSQLConnection().CreateCommand();
                command.CommandText = "Sp_Update_CtHanTt_ByMa_Kh";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Stt", "");
                command.Parameters.AddWithValue("@Ngay_Ct", Library.StrToDate(dteNgay_Ct_TT.Text));
                command.Parameters.AddWithValue("@Ma_Ct", "PTT");
                command.Parameters.AddWithValue("@Tk_Tt", txtTk_Tt.Text);
                command.Parameters.AddWithValue("@Ma_Dt", "");
                command.Parameters.AddWithValue("@Ma_DvCs", Element.sysMa_DvCs);
                SqlParameter parameter = new SqlParameter
                {
                    SqlDbType     = SqlDbType.Structured,
                    ParameterName = "@CtHanTt",
                    TypeName      = "TVP_CtHanTt",
                    Value         = Voucher.GetTVPValue("GLTHANHTOANCT", "TVP_CtHanTt", dtTableSource)
                };
                command.Parameters.Add(parameter);
                try
                {
                    int a = command.ExecuteNonQuery();
                }
                catch (Exception exception)
                {
                    command.CommandText = "WHILE @@TRANCOUNT > 0 ROLLBACK TRANSACTION";
                    command.CommandType = CommandType.Text;
                    command.Parameters.Clear();
                    command.ExecuteNonQuery();
                    EpointProcessBox.AddMessage("Có lỗi xảy ra :" + exception.Message);
                }
                this.btSave.Enabled = false;
            }
        }
Пример #18
0
        public virtual void Import_Excel(bool CheckAPI)
        {
            //string strMsg = (Element.sysLanguage == enuLanguageType.Vietnamese ? "Bạn có muốn ghi đè lên mẫu tin đã tồn tại không ?" : "Do you want to override exists data ?");
            bool Is_Avail = true;

            if (true)
            {
                SqlCommand command = SQLExec.GetNewSQLConnection().CreateCommand();
                command.CommandText = "OM_Import_DiscountProg";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Ma_DvCs", Element.sysMa_DvCs);
                //command.Parameters.AddWithValue("@IsImport", false);
                SqlParameter parameter = new SqlParameter
                {
                    SqlDbType     = SqlDbType.Structured,
                    ParameterName = "@EditDisc",
                    TypeName      = "TVP_DiscoutList",
                    Value         = dtImport
                };
                command.Parameters.Add(parameter);
                try
                {
                    command.ExecuteNonQuery();
                }
                catch (Exception exception)
                {
                    Is_Avail            = false;
                    command.CommandText = "WHILE @@TRANCOUNT > 0 ROLLBACK TRANSACTION";
                    command.CommandType = CommandType.Text;
                    command.Parameters.Clear();
                    command.ExecuteNonQuery();
                    EpointProcessBox.AddMessage("Có lỗi xảy ra :" + exception.Message);
                }
            }
            //return;
            if (!Is_Avail)
            {
                return;
            }


            Hashtable htParaBreaby = new Hashtable();

            htParaBreaby["MA_DVCS"]      = Element.sysMa_DvCs;
            htParaBreaby["LOCALMACHINE"] = System.Environment.MachineName;
            htParaBreaby["ISOVERWRITE"]  = chkIsOverride.Checked;
            DataSet ds = SQLExec.ExecuteReturnDs("OM_Import_DiscountProg_CheckValid", htParaBreaby, CommandType.StoredProcedure);

            DataTable dtCtkm     = ds.Tables[0];
            DataTable dtMa_vt    = ds.Tables[1];
            DataTable dtMa_Vt_Km = ds.Tables[2];


            if (dtCtkm.Rows.Count > 0)
            {
                strError += "\n" + "Chương trình KM/CK đã tồn tại trong hệ thống : ";
                foreach (DataRow dr in dtCtkm.Rows)
                {
                    strError += dr["Ma_CTKM"].ToString() + ",";
                }
            }
            if (dtMa_vt.Rows.Count > 0)
            {
                strError += "\n" + "Mã hàng bán không tồn tại : ";
                foreach (DataRow dr in dtMa_vt.Rows)
                {
                    strError += dr["Ma_Vt"].ToString() + ",";
                }
            }
            if (dtMa_Vt_Km.Rows.Count > 0)
            {
                strError += "\n" + "Mã hàng khuyến mãi không tồn tại : ";
                foreach (DataRow dr in dtMa_Vt_Km.Rows)
                {
                    strError += dr["Ma_Vt"].ToString() + ",";
                }
            }

            if (strError != string.Empty)
            {
                EpointProcessBox.AddMessage(strError);
            }
            else
            {
                Hashtable htPara = new Hashtable();
                htPara["MA_DVCS"]      = Element.sysMa_DvCs;
                htPara["LOCALMACHINE"] = System.Environment.MachineName;
                htPara["ISOVERWRITE"]  = chkIsOverride.Checked;
                if (SQLExec.Execute("OM_Import_DiscountProg_Valid", htPara, CommandType.StoredProcedure))
                {
                    EpointProcessBox.AddMessage("Import thành công!");
                }
                else
                {
                    EpointProcessBox.AddMessage("Import thất bại!");
                }
            }

            EpointProcessBox.AddMessage("Kết thúc");
        }
Пример #19
0
        public override void EpointRelease()
        {
            #region Import KPI

            if (OptionProcess == "KPIRANK")
            {
                try
                {
                    EpointProcessBox.AddMessage("Kết thúc import file " + strFileName);
                }
                catch (Exception ex)
                {
                    EpointProcessBox.AddMessage(ex.ToString());
                    EpointProcessBox.ShowOK(true);
                }
            }
            #endregion

            #region Send mail bang luong
            if (OptionProcess == "EMAIL")
            {
            }
            #endregion

            #region Tính Lương
            if (OptionProcess == "CALSALARY")
            {
                try
                {
                    EpointProcessBox.setValue(50);
                    this.CalSalary();
                    EpointProcessBox.AddMessage("Kết thúc ! ");
                }
                catch (Exception ex)
                {
                    EpointProcessBox.AddMessage(ex.ToString());
                    EpointProcessBox.ShowOK(true);
                }
            }
            #endregion
            #region Loading Lương
            if (OptionProcess == "LOADING")
            {
                try
                {
                }
                catch (Exception ex)
                {
                    EpointProcessBox.AddMessage(ex.ToString());
                    EpointProcessBox.ShowOK(true);
                }
            }
            #endregion
            #region Delete Lương
            if (OptionProcess == "DELETE")
            {
                try
                {
                    EpointProcessBox.setValue(30);
                    this.DeleteSalary();
                    //EpointProcessBox.CloseForm();
                    EpointProcessBox.AddMessage("Kết thúc ! ");
                }
                catch (Exception ex)
                {
                    EpointProcessBox.AddMessage(ex.ToString());
                    EpointProcessBox.ShowOK(true);
                }
            }
            #endregion
        }
Пример #20
0
        void btImport_Click(object sender, EventArgs e)
        {
            OptionProcess = "IMPORT";

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "xls files (*.xls;*.xlsx)|*.xls;*.xlsx";
            ofd.RestoreDirectory = true;

            if (Common.GetBufferValue("ImportExcelPathHRM") != string.Empty)
            {
                ofd.InitialDirectory = Common.GetBufferValue("ImportExcelPathHRM");
            }
            else
            {
                ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            }

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Common.SetBufferValue("ImportExcelPathHRM", System.IO.Path.GetDirectoryName(ofd.FileName));
                    strFileName = ofd.FileName;
                }
                catch { }


                try
                {
                    DataSet   dsImport = Common.ReadExcelToDataSet(strFileName);
                    DataTable dtResult = SQLExec.ExecuteReturnDt("DECLARE @KPICAMPAIGN AS TVP_KPICAMPAIGN SELECT * FROM @KPICAMPAIGN");
                    DataTable dtRatio  = SQLExec.ExecuteReturnDt("DECLARE @KPICAMPAIGN AS TVP_KPICAMPAIGN SELECT * FROM @KPICAMPAIGN");
                    foreach (DataTable table in dsImport.Tables)
                    {
                        if (table.Columns.Contains("Ma_Cbnv") && table.Columns.Contains("Segment")) // Import ket qua KPI
                        {
                            foreach (DataColumn cl in table.Columns)
                            {
                                string sColumnName = cl.ColumnName;
                                if (this.CheckItemId(sColumnName))// Nếu là chỉ tiêu KPI
                                {
                                    foreach (DataRow row in table.Rows)
                                    {
                                        DataRow drResult = dtResult.NewRow();
                                        drResult["KPIID"]    = row["Month"];
                                        drResult["ObjectID"] = row["Ma_CbNv"];
                                        drResult["Type"]     = row["Segment"];
                                        drResult["ItemID"]   = sColumnName;

                                        double amt = 0;
                                        double.TryParse(row[sColumnName].ToString().Replace("%", ""), out amt);
                                        drResult["Amt"] = amt;

                                        dtResult.Rows.Add(drResult);
                                    }
                                }
                            }
                        }
                        else if (table.Columns.Contains("Segment"))// Import Trong So KPI
                        {
                            foreach (DataColumn cl in table.Columns)
                            {
                                string sColumnName = cl.ColumnName;
                                if (this.CheckItemId(sColumnName))// Nếu là chỉ tiêu KPI
                                {
                                    foreach (DataRow row in table.Rows)
                                    {
                                        DataRow drRatio = dtRatio.NewRow();
                                        drRatio["KPIID"]    = row["Month"];
                                        drRatio["ObjectID"] = row["Segment"];
                                        drRatio["ItemID"]   = sColumnName;
                                        double amt = 0;
                                        double.TryParse(row[sColumnName].ToString().Replace("%", ""), out amt);
                                        drRatio["Amt"] = amt;
                                        dtRatio.Rows.Add(drRatio);
                                    }
                                }
                            }
                        }
                    }

                    bool Is_Avail = true;
                    if (true)
                    {
                        SqlCommand command = SQLExec.GetNewSQLConnection().CreateCommand();
                        command.CommandText = "Sp_IF_KPIResult";
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@UserId", Element.sysUser_Id);
                        command.Parameters.AddWithValue("@Is_OverWrite", Is_Avail);
                        SqlParameter parameter = new SqlParameter
                        {
                            SqlDbType     = SqlDbType.Structured,
                            ParameterName = "@KPICAMPAIGN",
                            TypeName      = "TVP_KPICAMPAIGN",
                            Value         = dtResult
                        };
                        command.Parameters.Add(parameter);
                        SqlParameter parameter1 = new SqlParameter
                        {
                            SqlDbType     = SqlDbType.Structured,
                            ParameterName = "@KPIRATIO",
                            TypeName      = "TVP_KPICAMPAIGN",
                            Value         = dtRatio
                        };

                        command.Parameters.Add(parameter1);
                        try
                        {
                            command.ExecuteNonQuery();
                        }
                        catch (Exception exception)
                        {
                            Is_Avail            = false;
                            command.CommandText = "WHILE @@TRANCOUNT > 0 ROLLBACK TRANSACTION";
                            command.CommandType = CommandType.Text;
                            command.Parameters.Clear();
                            command.ExecuteNonQuery();
                            EpointProcessBox.AddMessage("Có lỗi xảy ra :" + exception.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Không mở được bảng dữ liệu " + strFileName + "Error :" + ex.Message);
                }
            }
        }
Пример #21
0
        public override void EpointRelease()
        {
            //string strServerSource = Parameters.GetParaValue("SERVER_SOURCE").ToString();
            //Object strDBSource = Parameters.GetParaValue("DATABASE_SOURCE");
            string strDBSource = Element.sysDatabaseName.ToString();
            //string strServerDest = Parameters.GetParaValue("SERVER_DEST").ToString();
            //Object strDBSource = Element.sysDatabaseName;
            string strDBDest = Parameters.GetParaValue("DATABASE_DEST").ToString();

            DateTime dteNgay_Ct1   = Library.StrToDate(this.txtNgay_Ct1.Text);
            DateTime dteNgay_Ct2   = Library.StrToDate(this.txtNgay_Ct2.Text);
            string   strMa_Ct_List = txtMa_Ct.Text;

            if (!Common.CheckDataLocked(dteNgay_Ct1) || !Common.CheckDataLocked(dteNgay_Ct2))
            {
                //Common.MsgCancel("Dữ liệu đã khóa, liên hệ với nhà quản trị !");
                EpointProcessBox.AddMessage("Dữ liệu đã khóa, liên hệ với nhà quản trị !");
                return;
            }
            Hashtable ht = new Hashtable();

            //ht["SERVERSOURCE"] = strServerSource;
            //ht["SERVERDEST"] = strServerDest;
            ht["NGAY_CT1"]   = dteNgay_Ct1;
            ht["NGAY_CT2"]   = dteNgay_Ct2;
            ht["DBSOURCE"]   = strDBSource;
            ht["DBDEST"]     = strDBDest;
            ht["NAM"]        = Element.sysWorkingYear;
            ht["MA_CT_LIST"] = strMa_Ct_List;
            ht["MA_DVCS"]    = Element.sysMa_DvCs.ToString();

            try
            {
                Common.ShowStatus(Languages.GetLanguage("In_Process"));
                if (chkAll.Checked)
                {
                    EpointProcessBox.AddMessage("Đang chuyển số liệu chứng từ ");
                    SQLExec.Execute("sp_DuyetCt", ht, CommandType.StoredProcedure);
                }
                if (chkDanhMuc.Checked)
                {
                    EpointProcessBox.AddMessage("Đang chuyển danh mục ");
                    SQLExec.Execute("sp_Tranfer_DanhMuc", ht, CommandType.StoredProcedure);
                }
                if (chkDuDau.Checked)
                {
                    EpointProcessBox.AddMessage("Đang chuyển số dư đầu  ");
                    SQLExec.Execute("sp_Tranfer_DuDau", ht, CommandType.StoredProcedure);
                }
                if (chkTaiSan.Checked)
                {
                    EpointProcessBox.AddMessage("Đang chuyển chứng từ tài sản ");
                    SQLExec.Execute("sp_Tranfer_TaiSan", ht, CommandType.StoredProcedure);
                }
                //lock (this)
                //{
                //    if (chkDanhMuc.Checked)
                //    {
                //        string[] strArrPara = new string[] { "@ServerSource", "@ServerDest", "@DBSource", "@DBDest", "@Ma_DvCs" };
                //        object[] objArrPara = new object[] { strServerSource, strServerDest, strDBSource, strDBDest, Element.sysMa_DvCs };
                //        SQLExec.Execute("sp_Tranfer_DanhMuc", strArrPara, objArrPara, CommandType.StoredProcedure);
                //    }

                //}
                Element.sysNgay_Ct1 = Library.StrToDate(this.txtNgay_Ct1.Text);
                Element.sysNgay_Ct2 = Library.StrToDate(this.txtNgay_Ct2.Text);
                EpointProcessBox.AddMessage(Languages.GetLanguage("End_Process"));
                //EpointMessage.MsgOk(Languages.GetLanguage("End_Process"));
                //Common.EndShowStatus();
            }
            catch (Exception)
            {
                //Common.MsgOk("Không tìm thấy Database cần chuyển đến !");
                EpointProcessBox.AddMessage("Không tìm thấy Database cần chuyển đến !");
            }
        }
Пример #22
0
        public override void EpointRelease()
        {
            if (ReleaseType == "S")
            {
                string strMsgLog = string.Empty;
                try
                {
                    if (!Directory.Exists(FilePathZalo))
                    {
                        Directory.CreateDirectory(FilePathZalo);
                    }
                    object objImage;
                    string strMsg = string.Empty;
                    string AttachmentId = string.Empty;
                    string ZaloLink, File_Name, Description;
                    string FileImg;
                    //string FilePathZalo
                    //string strMa_Cbnv, strTen_Cbnv, strEmail, strMa_Kv, strMa_Loai2, strSubject;
                    EpointProcessBox.AddMessage("Lấy dữ liệu tin nhắn");

                    DataTable dtMsg = SQLExec.ExecuteReturnDt(" EXEC TUANVIET_OFFICIAL.dbo.Z_GetMessage_ToZalo " + MsgIDCur.ToString());

                    if (dtMsg == null || dtMsg.Rows.Count == 0)
                    {
                        EpointProcessBox.AddMessage("không lấy được dữ liệu tin nhắn");
                        return;
                    }
                    EpointProcessBox.AddMessage("Bắt đầu gửi tin nhắn");
                    //foreach (DataRow drmsg in dtMsg.Rows)
                    //{

                    DataRow drmsg = dtMsg.Rows[0];
                    //int MsgID = Convert.ToInt32(drmsg["Ident00"]);
                    ZaloLink    = drmsg["ZaloLink"].ToString();
                    objImage    = drmsg["File_Content"];
                    File_Name   = drmsg["File_Name"].ToString();
                    Description = drmsg["Description"].ToString();

                    FileImg = FilePathZalo + @"\" + (drmsg["File_Tag"].ToString() == string.Empty ? String.Empty : drmsg["File_ID"].ToString() + "." + drmsg["File_Tag"].ToString());

                    //Common.WriteToFileZaloLog("Start Send Message ToZalo : " + FileImg);
                    if (SaveZaloResource.LoadResourceImage(FileImg, objImage))
                    {
                        ZaloFile Zfile = new ZaloFile(FileImg);
                        Zfile.setMediaTypeHeader("Image/PNG");
                        JObject updatefile = client.uploadImageForOfficialAccountAPI(Zfile);
                        dynamic dynObjFile = JsonConvert.DeserializeObject(updatefile.ToString());
                        AttachmentId = dynObjFile.data.attachment_id;
                    }

                    //Get list employee in branch
                    //string strSQLEm = "Z_GetEmployee_ByTag " + drmsg["Ident00"] + "";

                    strMsg = File_Name + "\n" + Description + "\n" + ZaloLink;
                    if (true)
                    {
                        DataTable dtEmployee_Br = SQLExec.ExecuteReturnDt("EXEC Z_GetEmployee_ByTag " + MsgIDCur.ToString());
                        if (dtEmployee_Br == null || dtEmployee_Br.Rows.Count == 0)
                        {
                            return;
                        }

                        foreach (DataRow drR in dtEmployee_Br.Rows)
                        {
                            JObject jSendbr = client.sendImageMessageToUserIdByAttachmentId(drR["Zalo_ID"].ToString(), strMsg, AttachmentId);
                        }
                    }
                    else
                    {
                        JObject jSend_hungnv = client.sendImageMessageToUserIdByAttachmentId("5643947530772678208", strMsg, AttachmentId);
                    }
                    SQLExec.Execute("EXEC TUANVIET_OFFICIAL.dbo.Z_UpdateMessageZaloAfterSend " + MsgIDCur.ToString());
                    EpointProcessBox.AddMessage("Kết thúc");
                }
                catch (Exception ex)
                {
                    EpointProcessBox.AddMessage("Fail Send Message to Zalo : " + strMsgLog + "-------------\n" + ex.ToString());
                }
            }
            else if (ReleaseType == "G")
            {
                EpointProcessBox.AddMessage("Đang cập nhật thông tin người theo dõi!...................");
                UpdateFollower();
                ReleaseType = string.Empty;
                EpointProcessBox.AddMessage("....................Kết thúc...................");
            }
        }