Beispiel #1
0
 private void nav_TBarClick(object sender, ToolBarButtonClickEventArgs e)
 {
     if (e.Button.Equals(nav.cmd_add))
     {
         if (MessageBox.Show(PublicFunction.L_Get_Msg("msg", 218), this.Text, MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             if (vs.Rows.Count == 1 || (int)vs.Rows[vs.Rows.Count - 1].UserData != 2)
             {
                 nav.ToolBar_Click(e);
             }
             vs.Rows[vs.Rows.Count - 1]["LEA_ID"] = T_String.GetMax("MAX(LEA_ID)", "FILA15A").ToString("000");
             return;
         }
     }
     if (e.Button.Equals(nav.cmd_save))
     {
         for (int i = 1; i < vs.Rows.Count; i++)
         {
             vs.Rows[i]["SEQ_NO"] = i.ToString("000");
             if (vs.Rows[i].UserData + "" != "2")
             {
                 vs.Rows[i].UserData = 1;
             }
         }
     }
     nav.ToolBar_Click(e);
 }
Beispiel #2
0
 private void cmd_ok_Click(object sender, System.EventArgs e)
 {
     if (MessageBox.Show(PublicFunction.L_Get_Msg("msg", 123), this.Text, MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         DateTime d1  = (DateTime)dt1.Value;
         DateTime d2  = (DateTime)dt2.Value;
         string   sql = string.Format("Delete  From {0} where ATT_DT between '", Function.Common.Ints.tbChamCong) + d1.ToString("yyyy/MM/dd") + "'"
                        + " and '" + d2.ToString("yyyy/MM/dd") + "' and EMP_ID in (Select EMP_ID from FILB01A where " +
                        control1.GetWhere("", !ck1.Checked) + ") and (LOC_B1 is null or LOC_B1=0) ";
         if (!ck.Checked)
         {
             sql += " and (LOC_BT is null or LOC_BT=0)";
         }
         PublicFunction.SQL_Execute(sql);
         //ghi vao bang lich su chuyen va khoi tao du lieu
         int HIS_NO = 0;
         HIS_NO = T_String.GetMax("MAX(SEQ_NO)", "HistoryOfFILA06A");
         if (HIS_NO > 5000)
         {
             PublicFunction.SQL_Execute("DELETE HistoryOfFILA06A WHERE SEQ_NO<=" + HIS_NO + "-5000");
             PublicFunction.SQL_Execute("UPDATE HistoryOfFILA06A SET SEQ_NO=SEQ_NO-1 ");
             HIS_NO = T_String.GetMax("MAX(SEQ_NO)", "HistoryOfFILA06A");
         }
         sql = "insert into HistoryOfFILA06A values (" + HIS_NO + ",getdate(),NULL,'" + PublicFunction.A_UserID + "','" + T_String.sqlsql(control1.GetWhere("", !ck1.Checked))
               + ": From: " + d1.ToString("yyyy/MM/dd") + " TO: " + d2.ToString("yyyy/MM/dd") + "','Init ATT')";
         PublicFunction.SQL_Execute(sql);
         //end
         MessageBox.Show(PublicFunction.L_Get_Msg("Staff", 1));
     }
 }
Beispiel #3
0
        private void nav1_TBarClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (vs.Row <= 0)
            {
                return;
            }

            if (e.Button.Equals(nav1.cmd_add))
            {
                if (vs1.Rows[vs1.Row].UserData + "" == "2")
                {
                    return;
                }
                nav1.ToolBar_Click(e);
                vs1.Rows[vs1.Rows.Count - 1]["SHI_ID"] = vs.Rows[vs.Row]["SHI_ID"];
                vs1.Rows[vs1.Rows.Count - 1]["SEQ_N1"] = T_String.GetMax("MAX(SEQ_N1)", "FILC02B", "SHI_ID=N'" + vs.Rows[vs.Row]["SHI_ID"] + "'");
                vs1.Rows[vs1.Rows.Count - 1]["SEQ_NO"] = (vs1.Rows.Count - 1).ToString("00");
                vs1.Rows[vs1.Rows.Count - 1]["TYP_ID"] = "ATT_HR";
                vs1.Rows[vs1.Rows.Count - 1]["LAT_BT"] = "1";
                return;
            }
            if (e.Button.Equals(nav1.cmd_save))
            {
                Boolean a = true;
                vs.Select();
                for (int i = 1; i < vs1.Rows.Count; i++)
                {
                    if (vs1.Rows[i]["SEQ_NO"] + "" != i.ToString("00"))
                    {
                        a = false;
                    }
                }
                for (int i = 1; i < vs1.Rows.Count; i++)
                {
                    vs1.Rows[i]["SEQ_NO"] = i.ToString("00");
                    if (vs1.Rows[i].UserData + "" != "2")
                    {
                        if (vs1.Rows[i].UserData + "" == "1")
                        {
                            vs1.Rows[i]["LST_NM"] = PublicFunction.A_UserID;
                            vs1.Rows[i]["LST_DT"] = T_String.GetDate().ToString("yyyy/MM/dd HH:mm");
                        }
                        if (!a)
                        {
                            vs1.Rows[i].UserData  = 1;
                            vs1.Rows[i]["LST_NM"] = PublicFunction.A_UserID;
                            vs1.Rows[i]["LST_DT"] = T_String.GetDate().ToString("yyyy/MM/dd HH:mm");
                        }
                    }
                    else
                    {
                        vs1.Rows[i]["BLT_NM"] = vs1.Rows[i]["LST_NM"] = PublicFunction.A_UserID;
                        vs1.Rows[i]["LST_DT"] = vs1.Rows[i]["BLT_DT"] = T_String.GetDate().ToString("yyyy/MM/dd HH:mm");
                    }
                }
            }
            nav1.ToolBar_Click(e);
        }
Beispiel #4
0
        private void change()
        {
            string YYY_MM = DateTime.Parse(dt.Value + "").ToString("yyyyMM");
            int    d      = T_String.IsNullTo0(day.Text);

            if (d <= 0 || d > 31)
            {
                l.Text = PublicFunction.L_Get_Msg("msg", 89);
                day.Focus();
                return;
            }
            else
            {
                int c = T_String.GetMax("Count(*)", "FILC03A", "EMP_ID=N'" + EMP_ID + "' and YYY_MM=N'" + YYY_MM + "'");
                if (c <= 1)
                {
                    string st = "";
                    st     = label4 + ": " + txt.Text + " - " + EMP_NM + " \n ";
                    st     = label1 + ": " + YYY_MM + " \n ";
                    st     = PublicFunction.L_Get_Msg("msg", 87);
                    l.Text = st;
                }
                else
                {
                    string sql = "";
                    sql = "update FILC03A set DAY_" + d.ToString("00") + "=N'" + cb.Text + "' where EMP_ID=N'"
                          + EMP_ID + "' and YYY_MM=N'" + YYY_MM + "'";
                    PublicFunction.SQL_Execute(sql);
                    vs.Rows.Count++;
                    int r = vs.Rows.Count - 1;
                    vs.Rows[r][0]        = r;
                    vs.Rows[r]["EMP_ID"] = EMP_ID;
                    vs.Rows[r]["EMP_I1"] = EMP_I1;
                    vs.Rows[r]["EMP_NM"] = EMP_NM;
                    vs.Rows[r]["DEP_ID"] = DEP_ID;
                    vs.Rows[r]["DT"]     = DateTime.Parse(dt.Value + "").ToString("yyyy/MM") + "/" + d.ToString("00");
                    vs.Rows[r]["SHI_ID"] = cb.Text;
                    vs.AutoSizeCols();


                    string st = "";
                    st     = label4 + ": " + txt.Text + " - " + EMP_NM + " \n ";
                    st     = label1 + ": " + YYY_MM + " \n ";
                    st     = PublicFunction.L_Get_Msg("Staff", 1);
                    l.Text = st;
                }
            }

            EMP_ID          = EMP_I1 = EMP_NM = DEP_ID = "";
            txt.Text        = "";
            txt_EMP_NM.Text = "";
            day.Text        = "";
            txt.Focus();
        }
Beispiel #5
0
 private void nav_TBarClick(object sender, ToolBarButtonClickEventArgs e)
 {
     if (e.Button.Equals(nav.cmd_add))
     {
         if (vs.Rows.Count == 1 || (int)vs.Rows[vs.Rows.Count - 1].UserData != 2)
         {
             nav.ToolBar_Click(e);
         }
         vs.Rows[vs.Rows.Count - 1]["VAC_ID"] = T_String.GetMax("MAX(VAC_ID)", "FILA06A").ToString("000");
         return;
     }
     nav.ToolBar_Click(e);
 }
Beispiel #6
0
 private void cmd_del_Click(object sender, System.EventArgs e)
 {
     if (MessageBox.Show(this, PublicFunction.L_Get_Msg("msg", 16) + " (" + dt2.Text + ")?", this.Text, MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         string sql = "Delete From FILC03A where YYY_MM='" + dt2.Text + "'";
         PublicFunction.SQL_Execute(sql);
         sql = "Insert Into GP_HISTORY values(" + T_String.GetMax("MAX(SEQ_NO)", "GP_HISTORY")
               + ",N'" + PublicFunction.A_UserID + "'"
               + ",'" + T_String.GetDate().ToString("yyyy/MM/dd HH:mm:ss") + "'"
               + ",N'" + dt2.Text + "')";
         PublicFunction.SQL_Execute(sql);
     }
 }
Beispiel #7
0
        private void frmTaGraduationHistory_Closed(object sender, System.EventArgs e)
        {
            int max = T_String.GetMax("MAX(SEQ_NO)", "FILB08A", "EMP_ID=N'" + wh + "'");

            Func.RecordSet rs = new Func.RecordSet("Select * from FILB08A where EMP_ID=N'" + wh + "' and SEQ_NO=" + (max - 1), PublicFunction.C_con);
            if (rs.rows > 0)
            {
                GRA_ID = rs.record(0, "GRA_ID");
            }
            else
            {
                GRA_ID = "";
            }
        }
Beispiel #8
0
 private void nav_TBarClick(object sender, ToolBarButtonClickEventArgs e)
 {
     if (e.Button.Equals(nav.cmd_add))
     {
         if (vs.Rows.Count == 1 || (int)vs.Rows[vs.Rows.Count - 1].UserData != 2)
         {
             nav.ToolBar_Click(e);
         }
         vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = T_String.GetMax("MAX(SEQ_NO)", "FILA17AA");
         vs.Rows[vs.Rows.Count - 1]["ATT_BT"] = 1;
         vs.Rows[vs.Rows.Count - 1]["CON_TP"] = 1;
         return;
     }
     nav.ToolBar_Click(e);
 }
Beispiel #9
0
		private void nav_TBarClick(object sender, ToolBarButtonClickEventArgs e)
		{					
			if (e.Button.Equals(nav.cmd_add))
			{
				if (vs.Rows.Count==1 || (int)vs.Rows[vs.Rows.Count-1].UserData!=2)					
					nav.ToolBar_Click(e);									
				vs.Rows[vs.Rows.Count-1]["SEQ_NO"]=T_String.GetMax("MAX(SEQ_NO)","FILB01AA");
				vs.Rows[vs.Rows.Count-1]["EMP_ID"]=EMP_ID;
				if(vs.Rows.Count-2>0)
					vs.Rows[vs.Rows.Count-1]["ADD_DR"]=vs.Rows[vs.Rows.Count-2]["ADD_DR"];
				else
				vs.Rows[vs.Rows.Count-1]["ADD_DR"]=ADD_DR;
				return;
			}
			nav.ToolBar_Click(e);
		}	
Beispiel #10
0
        private void GetOldSalary(int row, string EMP_ID)
        {
            vs.Rows[row]["SEQ_NO"] = T_String.GetMax("MAX(SEQ_NO)", "FILD03A", "EMP_ID=N'" + EMP_ID + "'");
            string sql;

            sql = "Select * from FILD03A where EMP_ID=N'" + EMP_ID + "' and (DON_AP=0 or DON_AP is null) ORDER BY SEQ_NO DESC";
            Func.RecordSet rs = new Func.RecordSet(sql, PublicFunction.C_con);
            if (rs.rows <= 0)
            {
                return;
            }
            for (int i = 0; i < rsitem.rows; i++)
            {
                vs.Rows[vs.Row][rsitem.record(i, "COL_NM")] = rs.record(0, rsitem.record(i, "COL_NM"));
            }
        }
Beispiel #11
0
        private void frmTaATM_Closed(object sender, System.EventArgs e)
        {
            int max = T_String.GetMax("MAX(SEQ_NO)", "FILB06A", "EMP_ID=N'" + wh + "'");

            Func.RecordSet rs = new Func.RecordSet("Select * from FILB06A where EMP_ID=N'" + wh + "' and SEQ_NO=" + (max - 1), PublicFunction.C_con);
            if (rs.rows > 0)
            {
                ACC_NO = rs.record(0, "ACC_NO");
                ACC_NM = rs.record(0, "ACC_NM");
                BNK_NM = rs.record(0, "BNK_NM");
            }
            else
            {
                ACC_NO = ACC_NM = BNK_NM = "";
            }
        }
Beispiel #12
0
 private void vs_AfterEdit(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
 {
     if (vs.Cols[e.Col].Name == "DON_AP")
     {
         GP8000.Payroll.frmTaTXT dlg = new GP8000.Payroll.frmTaTXT();
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             vs.Rows[e.Row]["REA_DR"] = dlg.txt.Text;
             vs.Rows[e.Row]["LST_NM"] = PublicFunction.A_UserID;
             vs.Rows[e.Row]["LST_DT"] = T_String.GetDate().ToString("yyyy/MM/dd HH:mm");
             nav.SaveRow(e.Row);
         }
         else
         {
             vs.Rows[e.Row]["DON_AP"] = false;
         }
     }
     if (vs.Cols[e.Col].Name == "VAC_BT")
     {
         if (T_String.GetMax("COUNT(EMP_ID)", "FILB01A", "EMP_ID=N'" +
                             vs.Rows[e.Row]["EMP_ID"] + "' and VAC_BT=1") > 1)
         {
             MessageBox.Show(PublicFunction.L_Get_Msg("msg", 120));
             vs.Rows[e.Row]["VAC_BT"] = false;
         }
         else
         {
             frmTaVacate dlg1 = new frmTaVacate();
             dlg1.EMP_ID.Text = vs.Rows[e.Row]["EMP_ID"] + "";
             dlg1.EMP_NM.Text = vs.Rows[e.Row]["EMP_NM"] + "";
             dlg1.DEP_ID.Text = vs.GetDataDisplay(e.Row, "DEP_ID");
             dlg1.POS_ID.Text = vs.GetDataDisplay(e.Row, "EMP_I1");
             if (dlg1.ShowDialog() == DialogResult.OK)
             {
                 vs.Rows[e.Row]["LST_NM"] = PublicFunction.A_UserID;
                 vs.Rows[e.Row]["LST_DT"] = T_String.GetDate().ToString("yyyy/MM/dd HH:mm");
                 nav.SaveRow(e.Row);
             }
             else
             {
                 vs.Rows[e.Row]["VAC_BT"] = false;
             }
         }
     }
 }
Beispiel #13
0
 private void nav_TBarClick(object sender, ToolBarButtonClickEventArgs e)
 {
     if (e.Button.Equals(nav.cmd_add))
     {
         if (vs.Rows.Count >= 2)
         {
             return;
         }
         if (vs.Rows.Count == 1 || (int)vs.Rows[vs.Rows.Count - 1].UserData != 2)
         {
             nav.ToolBar_Click(e);
         }
         TextBoxAndVS.D_AddNewOrEdit(groupBox1, false);
         vs.Rows[vs.Rows.Count - 1]["ACT_BT"] = 1;
         textBox1.Text = T_String.GetMax("MAX(COM_ID)", "FILA01A") + "";
         return;
     }
     if (e.Button.Equals(nav.cmd_save))
     {
         try
         {
             TextBoxAndVS.D_GetDataFromTextBox(groupBox1, vs);
             if ((int)vs.Rows[vs.Row].UserData != 2)
             {
                 vs.Rows[vs.Row].UserData = 1;
             }
             nav.ToolBar_Click(e);
             return;
         }
         catch (Exception) {}
     }
     if (e.Button.Equals(nav.cmd_refresh))
     {
         nav.ToolBar_Click(e);
         show_data();
         return;
     }
     if (e.Button.Equals(nav.cmd_delete))
     {
         nav.DeleteRow(vs.Row);
         return;
     }
     nav.ToolBar_Click(e);
 }
Beispiel #14
0
 private void vs1_DoubleClick(object sender, System.EventArgs e)
 {
     if (vs1.Row > 0)
     {
         nav3.ToolBar_Click(new ToolBarButtonClickEventArgs(nav3.cmd_add));
         int m = T_String.GetMax("MAX(ID)", "SYS_LABEL_VS", "NAME=N'" + vs1.Rows[vs1.Row]["ID"] + "'");
         if (vs1.Rows.Count - 2 > 0)
         {
             if (m <= T_String.IsNullTo0(vs2.Rows[vs2.Rows.Count - 2]["ID"] + ""))
             {
                 m = T_String.IsNullTo0(vs2.Rows[vs2.Rows.Count - 2]["ID"] + "") + 1;
             }
         }
         vs2.Rows[vs2.Rows.Count - 1]["ID"]    = m;
         vs2.Rows[vs2.Rows.Count - 1]["NAME"]  = vs1.Rows[vs1.Row]["ID"];
         vs2.Rows[vs2.Rows.Count - 1]["FNAME"] = vs1.Rows[vs1.Row]["NAME"];
         vs2.AutoSizeCols();
     }
 }
Beispiel #15
0
 private void nav3_TBarClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
 {
     if (vs1.Row > 0)
     {
         nav3.ToolBar_Click(e);
         if (e.Button.Equals(nav3.cmd_add))
         {
             int m = T_String.GetMax("MAX(ID)", "SYS_LABEL_VS", "NAME=N'" + vs1.Rows[vs1.Row]["ID"] + "'");
             if (vs1.Rows.Count - 2 > 0)
             {
                 if (m <= T_String.IsNullTo0(vs2.Rows[vs2.Rows.Count - 2]["ID"] + ""))
                 {
                     m = T_String.IsNullTo0(vs2.Rows[vs2.Rows.Count - 2]["ID"] + "") + 1;
                 }
             }
             vs2.Rows[vs2.Rows.Count - 1]["ID"]   = m;
             vs2.Rows[vs2.Rows.Count - 1]["NAME"] = vs1.Rows[vs1.Row]["ID"];
         }
     }
 }
Beispiel #16
0
        private void nav_TBarClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button.Equals(nav.cmd_add))
            {
                if (vs.Rows.Count == 1 || (int)vs.Rows[vs.Rows.Count - 1].UserData != 2)
                {
                    nav.ToolBar_Click(e);
                }
                vs.Rows[vs.Rows.Count - 1]["JUR_ID"] = T_String.GetMax("MAX(JUR_ID)", "FILA14A").ToString("000");
                return;
            }
            if (e.Button.Equals(nav.cmd_delete))
            {
                if (T_String.IsNullTo0(T_String.GetDataFromSQL("Count(EMP_ID)", "FILB01A", vs.Cols[2].Name + "=N'" + vs.Rows[vs.Row][2] + "' ")) > 0)
                {
                    MessageBox.Show(PublicFunction.L_Get_Msg("msg", 217));

                    return;
                }
            }
            nav.ToolBar_Click(e);
        }
Beispiel #17
0
        private void cmd_ok_Click(object sender, System.EventArgs e)
        {
            if (MessageBox.Show(this, PublicFunction.L_Get_Msg("msg", 98), this.Text, MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);
                con.Open();
                string         td     = T_String.GetDate().ToString("yyyy/MM/dd");
                string         sql2   = "Select * from FILD01A where BAS_BT=1 ";
                Func.RecordSet rsitem = new Func.RecordSet(sql2, PublicFunction.C_con);
                for (int i = vs1.Rows.Count - 1; i > 0; i--)
                {
                    string         EMP_ID = vs1.Rows[i]["EMP_ID"] + "";
                    SqlTransaction tran   = con.BeginTransaction();
                    try
                    {
                        string sql = "", sql1, vl = "";
                        sql = "Insert Into FILD03A(EMP_ID,SEQ_NO,CHA_DT,NOT_DR,BLT_NM,BLT_DT";
                        vl  = T_String.GetMax("MAX(SEQ_NO)", "FILD03A", "EMP_ID=N'" + EMP_ID + "'") + "";
                        vl  = "(N'" + EMP_ID + "'," + vl + ",'" + ((DateTime)dt1.Value).ToString("yyyy/MM/dd") + "',N'" +
                              T_String.sqlsql(txt_not.Text) + "',N'" + PublicFunction.A_UserID + "','" + td + "'";
                        sql1 = "Select * from FILD03A where EMP_ID=N'" + EMP_ID + "' and (DON_AP=0 or DON_AP is null) ORDER BY SEQ_NO DESC";
                        Func.RecordSet rs = new Func.RecordSet(sql1, PublicFunction.C_con);

                        for (int m = 0; m < rsitem.rows; m++)
                        {
                            sql += "," + rsitem.record(m, "COL_NM");
                            if (rsitem.record(m, "COL_NM") == cb.SelectedValue + "")
                            {
                                if (PublicFunction.CUS_ID == "51" && rsitem.record(m, "COL_NM") == "BacLuong")
                                {
                                    vl += ",'" + txt.Value + "'";
                                }
                                else
                                {
                                    vl += "," + txt.Value;
                                }
                            }
                            else
                            {
                                if (rs.record(0, rsitem.record(m, "COL_NM")) + "" == "" || (rs.rows < 0))
                                {
                                    vl += ",Default";
                                }
                                else
                                {
                                    if (PublicFunction.CUS_ID == "51" && rsitem.record(m, "COL_NM") == "BacLuong")
                                    {
                                        vl += ",'" + rs.record(0, rsitem.record(m, "COL_NM")) + "'";
                                    }
                                    else
                                    {
                                        vl += "," + rs.record(0, rsitem.record(m, "COL_NM"));
                                    }
                                }
                            }
                        }

                        sql = sql + ") values " + vl + ")";
                        SqlCommand cmd = new SqlCommand(sql, con, tran);
                        cmd.ExecuteNonQuery();
                        tran.Commit();
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        MessageBox.Show(ex.Message);
                    }
                }
                MessageBox.Show(PublicFunction.L_Get_Msg("Staff", 1));
            }
        }
Beispiel #18
0
        private void show()
        {
            vs.Visible = false;
            SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            string sql = "";

            sql = "Select * from FILE01A";
            Func.RecordSet rs2 = new Func.RecordSet(sql, con);
            ArrayList      a   = new ArrayList();
            ArrayList      b   = new ArrayList();

            for (int i = 0; i < rs2.rows; i++)
            {
                a.Add(rs2.record(i, "LAB_NO"));
                int tam = T_String.IsNullTo0(T_String.GetDataFromSQL("MAX(SEQ_N1)", "FILE03A", "LAB_NO=N'" + rs2.record(i, "LAB_NO") + "'"));
                if (tam == 1)
                {
                    tam = T_String.IsNullTo0(rs2.record(i, "STT_N2") + "");
                }
                b.Add(tam);
            }
            double maxx = T_String.GetMax("MAX(SEQ_N2)", "FILE03A");

            sql = "Select EMP_ID,EMP_I1,EMP_NM,INH_DT,TYP_ID,POS_ID,DEP_ID from FILB01A where (VAC_BT is null or VAC_BT=0)";
            if (NEW_BT)
            {
                sql = sql + " and isnull(NEW_BT,0)=1 and isnull(LCK_BT,0)=0";
            }
            if (wh != "")
            {
                sql += " and " + wh;
            }
            DateTime dt1 = T_String.GetDate();

            dt1  = dt1.AddDays(T_String.IsNullTo0(day));
            sql += " and EMP_ID not in(Select Distinct EMP_ID from FILE03A where LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                   + "' or LIM_NO=1)";
            vs.Rows.Count = 1;
            Func.RecordSet rs = new Func.RecordSet(sql, con);
            for (int i = 0; i < rs.rows; i++)
            {
                try
                {
                    sql = "Select * from FILE03A where EMP_ID=N'" + rs.record(i, "EMP_ID") + "' ORDER BY LAB_ST DESC";
                    Func.RecordSet rslb = new Func.RecordSet(sql, con);
                    DateTime       dt;
                    int            max;
                    if (rslb.rows == 0)
                    {
                        dt  = DateTime.Parse(rs.record(i, "INH_DT"));
                        max = 1;
                    }
                    else
                    {
                        dt = DateTime.Parse(rslb.record(0, "LAB_ED"));
                        //dt=dt.AddDays(1);
                        max = 1 + T_String.IsNullTo0(rslb.record(0, "SEQ_NO"));
                    }
//					if(ngaytinh>0)//ngaytinh
//					{
//						if(dt.Day<ngaytinh)
//							dt=new DateTime (dt.Year,dt.Month,1);
//						else
//						{
//							dt=dt.AddMonths(1);
//							dt=new DateTime (dt.Year,dt.Month,1);
//						}
//					}
                    if (LAB_N1 != "")
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and a.LAB_NO=N'" + LAB_N1 + "' and a.LAB_NO=b.LAB_NO";
                    }
                    else
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and SEQ_NO=" + max + " and a.LAB_NO=b.LAB_NO";
                    }
                    Func.RecordSet rs1 = new Func.RecordSet(sql, con);
                    if (rs1.rows == 0)
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and REP_BT=1 and a.LAB_NO=b.LAB_NO";
                        rs1 = new Func.RecordSet(sql, con);
                    }
                    try
                    {
                        if (rs1.rows > 0 && rs1.record(0, "LAB_ID") + "" != "" && (this.LAB_NO == "" || this.LAB_NO == rs1.record(0, "LAB_NO")))
                        {
                            vs.Rows.Count++;
                            vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                            vs.Rows[vs.Rows.Count - 1][0]        = vs.Rows.Count - 1;
                            vs.Rows[vs.Rows.Count - 1]["EMP_ID"] = rs.record(i, "EMP_ID");
                            vs.Rows[vs.Rows.Count - 1]["EMP_I1"] = rs.record(i, "EMP_I1");
                            vs.Rows[vs.Rows.Count - 1]["EMP_NM"] = rs.record(i, "EMP_NM");
                            vs.Rows[vs.Rows.Count - 1]["TYP_ID"] = rs.record(i, "TYP_ID");
                            vs.Rows[vs.Rows.Count - 1]["POS_ID"] = rs.record(i, "POS_ID");
                            vs.Rows[vs.Rows.Count - 1]["DEP_ID"] = rs.record(i, "DEP_ID");
                            vs.Rows[vs.Rows.Count - 1]["INH_DT"] = rs.record(i, "INH_DT");
                            vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = rs1.record(0, "SEQ_NO");
                            if (date != "")
                            {
                                vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = date;
                                dt = DateTime.Parse(date);
                            }
                            else
                            {
                                vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = dt.ToString("yyyy/MM/dd");
                            }

                            if (rs1.record(0, "LIM_NO") + "" == "True")
                            {
                                vs.Rows[vs.Rows.Count - 1]["LIM_NO"] = "True";
                            }
                            else
                            {
                                if (rs1.record(0, "YYY_YY") + "" != "")
                                {
                                    dt = dt.AddYears(T_String.IsNullTo0(rs1.record(0, "YYY_YY") + ""));
                                }
                                else
                                {
                                    dt = dt.AddMonths(T_String.IsNullTo0(rs1.record(0, "MMM_MM") + ""));
                                }
                                if (ngaytinh > 0)                             //ngaytinh
                                {
                                    if (dt.Day < ngaytinh)
                                    {
                                        dt = new DateTime(dt.Year, dt.Month, 1);
                                    }
                                    else
                                    {
                                        dt = dt.AddMonths(1);
                                        dt = new DateTime(dt.Year, dt.Month, 1);
                                    }
                                }
                                if (ngaytru)
                                {
                                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.AddDays(-1).ToString("yyyy/MM/dd");
                                }
                                else
                                {
                                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.ToString("yyyy/MM/dd");
                                }
                            }
                            vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = rs1.record(0, "LAB_NO");
                            vs.Rows[vs.Rows.Count - 1]["LAB_TP"] = rs1.record(0, "LAB_TP");
                            // LAB_ID  ma so hop dong
                            string LAB_ID = rs1.record(0, "LAB_ID");
                            LAB_ID = LAB_ID.Replace("#", rs.record(i, "EMP_ID") + "");
                            LAB_ID = LAB_ID.Replace("&", rs.record(i, "EMP_I1") + "");
                            if (LAB_ID.IndexOf("@") >= 0)
                            {
                                int index = a.IndexOf(rs1.record(0, "LAB_NO"));
                                int vl    = T_String.IsNullTo0(b[index] + "") + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                                vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                                string st = "000000000000";
                                b[index] = vl;
                                st       = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                                LAB_ID   = LAB_ID.Replace("@", vl.ToString(st));
                            }

                            DateTime ngayky = DateTime.Parse(vs.Rows[vs.Rows.Count - 1]["LAB_ST"] + "");
                            LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yyyy") + "");
                            LAB_ID = LAB_ID.Replace("*(Month)", ngayky.ToString("MM") + "");
                            LAB_ID = LAB_ID.Replace("*(Day)", ngayky.ToString("dd") + "");

                            int count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE03A", "EMP_ID=N'" + rs.record(i, "EMP_ID") + "'"));
                            LAB_ID = LAB_ID.Replace("*(Count)", (count + 1) + "");
                            LAB_ID = LAB_ID.Replace("*(DEP)", rs.record(i, "DEP_ID") + "");
                            LAB_ID = LAB_ID.Replace("*(POS)", rs.record(i, "POS_ID") + "");
                            LAB_ID = LAB_ID.Replace("*(NATURE)", rs.record(i, "TYP_ID") + "");



                            ////////////
                            vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = LAB_ID;

                            vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                            maxx++;
                        }
                    }
                    catch (Exception ex) { MessageBox.Show(ex.Message); vs.Rows.Count--; }
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                lb.Text   = ((int)(i * 100) / rs.rows) + "% - " + rs.record(i, "EMP_NM");
                pro.Value = (int)(i * 100) / rs.rows;
            }
            vs.AutoSizeCols();
            pro.Value = 100;
            con.Close();
            this.Close();
            vs.Visible = true;
        }
Beispiel #19
0
        private void cmd_cal_Click(object sender, System.EventArgs e)
        {
            if (MessageBox.Show(this, PublicFunction.L_Get_Msg("msg", 78), this.Text, MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }
            ArrayList a = new ArrayList();

            for (int n = 1; n < vs.Rows.Count; n++)
            {
                if (vs.Rows[n].UserData + "" == "1")
                {
                    a.Add(n);
                    string st = vs.Rows[n]["NOT_DR"] + "";
                    if (st.IndexOf("Sign") < 0)
                    {
                        vs.Rows[n]["NOT_OR"] = vs.Rows[n]["NOT_DR"];
                    }
                }
            }
            nav_TBarClick(nav.cmd_save, new ToolBarButtonClickEventArgs(nav.cmd_save));
            Func.RecordSet rsTypeShift = new Func.RecordSet("Select * from GP_SYS_SHIFT", PublicFunction.C_con);
            Func.RecordSet Set         = new Func.RecordSet("Select * from GP_SYS_SETTING", PublicFunction.C_con);
            SqlConnection  con         = new SqlConnection(PublicFunction.C_con.ConnectionString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            int dem = 0, i = 0;

            for (int m = 0; m < a.Count; m++)
            {
                i = (int)a[m];
                string   EMP_ID = vs.Rows[i]["EMP_ID"] + "";
                DateTime d1     = DateTime.Parse(vs.Rows[i]["ATT_DT"] + "");

                string         SHI_ID = vs.Rows[i]["SHI_ID"] + "";
                string         sql    = "Select * from FILC02B where SHI_ID=N'" + SHI_ID + "' ORDER BY SEQ_NO";
                Func.RecordSet rsca   = new Func.RecordSet(sql, con);

                ArrayList Ca  = new ArrayList();
                ArrayList ATT = new ArrayList();
                for (int j = 0; j < rsca.rows; j++)
                {
                    Ca.Add(rsca.record(j, "ONN_TM"));
                    Ca.Add(rsca.record(j, "OFF_TM"));
                }
                Ca.Add(0);
                Ca.Add(0);
                Ca.Add(0);
                Ca.Add(0);
                for (int j = 1; j <= 10; j++)
                {
                    ATT.Add(T_String.IsNullTo00(vs.Rows[i]["ONN_" + j.ToString("00")] + ""));
                    ATT.Add(T_String.IsNullTo00(vs.Rows[i]["OFF_" + j.ToString("00")] + ""));
                }
                TaAttendance tm = new TaAttendance(EMP_ID, d1.ToString("yyyy/MM/dd"), con, Ca, ATT, SHI_ID, rsca, Set, rsTypeShift);
                tm.tb     = "FILC06A";
                tm.NIG_TM = T_String.IsNullTo00(vs.Rows[i]["NIG_TM"] + "");
                tm.NOT_DD = vs.Rows[i]["NOT_DR"] + "";
                tm.UpdateSql();
                ForCal(EMP_ID, d1.ToString("yyyy/MM/dd"));
                dem++;
            }
            int vat = T_String.GetMax("MAX(SEQ_NO)", "FILC10A");

            for (int m = 0; m < a.Count; m++)
            {
                string   EMP_ID = vs.Rows[i]["EMP_ID"] + "";
                DateTime d1     = DateTime.Parse(vs.Rows[i]["ATT_DT"] + "");
                TaAttendance.AbsentToVacate(EMP_ID, d1.ToString("yyyy/MM/dd"), con, "FILC06A");
            }
            if (T_String.GetMax("MAX(SEQ_NO)", "FILC10A") > vat)
            {
                frmTaAbsentVacate dlg = new frmTaAbsentVacate();
                dlg.Tag = this.Tag;
                dlg.ShowDialog();
            }
            if (dem > 0)
            {
                int row = vs.Row;
                nav.Show_VS(nav.Where + "");
                if (row > 0 && vs.Rows.Count > 1)
                {
                    vs.Row = row;
                }
            }
            vs.Tag = "";
            CheckCols();
        }
Beispiel #20
0
        private void nav_TBarClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button.Equals(nav.cmd_add))
            {
                if (vs.Rows.Count == 1 || (int)vs.Rows[vs.Rows.Count - 1].UserData != 2)
                {
                    nav.ToolBar_Click(e);
                }
                TextBoxAndVS.D_AddNewOrEdit(groupBox1, false);
                return;
            }
            if (e.Button.Equals(nav.cmd_save))
            {
                try
                {
                    TextBoxAndVS.D_GetDataFromTextBox(groupBox1, vs);
                    if ((int)vs.Rows[vs.Row].UserData != 2)
                    {
                        vs.Rows[vs.Row].UserData = 1;
                    }
                    else
                    {
                        vs.Rows[vs.Row]["RPT_ID"] = T_String.GetMax("MAX(RPT_ID)", "FILE07A") + "";

                        vs2.Rows.Count++;
                        int row = vs2.Rows.Count - 1;
                        vs2.Rows[row].UserData  = 2;
                        vs2.Rows[row][0]        = row;
                        vs2.Rows[row]["SEQ_NO"] = row.ToString("000");
                        vs2.Rows[row]["RPT_ID"] = vs.Rows[vs.Row]["RPT_ID"];
                        vs2.Rows[row]["COL_ID"] = "EMP_ID";
                        vs2.Rows[row]["COL_NM"] = "WID";
                        vs2.Rows[row]["TAB_DR"] = "FILB01A";
                        vs2.Rows[row]["SHO_BT"] = 1;
                        vs2.Rows[row]["WID_VL"] = 80;
                        nav2.SaveRow(row);

                        vs2.Rows.Count++;
                        row = vs2.Rows.Count - 1;
                        vs2.Rows[row].UserData  = 2;
                        vs2.Rows[row][0]        = row;
                        vs2.Rows[row]["SEQ_NO"] = row.ToString("000");
                        vs2.Rows[row]["RPT_ID"] = vs.Rows[vs.Row]["RPT_ID"];
                        vs2.Rows[row]["COL_ID"] = "EMP_NM";
                        vs2.Rows[row]["COL_NM"] = "Name";
                        vs2.Rows[row]["TAB_DR"] = "FILB01A";
                        vs2.Rows[row]["SHO_BT"] = 1;
                        vs2.Rows[row]["WID_VL"] = 80;
                        nav2.SaveRow(row);
                        vs2.AutoSizeCols();
                    }
                    nav.ToolBar_Click(e);
                    return;
                }
                catch (Exception) {}
            }
            if (e.Button.Equals(nav.cmd_refresh))
            {
                nav.ToolBar_Click(e);
                show_data();
                return;
            }
            if (e.Button.Equals(nav.cmd_delete))
            {
                nav.DeleteRow(vs.Row);
                return;
            }
            nav.ToolBar_Click(e);
        }
        private void show()
        {
            DateTime dt5;
            double   seqMax = 0;

            vs.Visible = false;
            string        sql = "";
            SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            double maxx = T_String.GetMax("MAX(SEQ_N2)", "FILE06A");
            double max  = T_String.GetMax("MAX(SEQ_N1)", "FILE06A", "LAB_NO=N'" + LAB_NO + "'") - 1;

            DateTime dt6 = T_String.GetDate();

            dt6 = dt6.AddDays(T_String.IsNullTo0(day));
            for (int i = 1; i < vs1.Rows.Count; i++)
            {
                sql = "Select * from FILE03A where EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "' ORDER BY SEQ_NO DESC";
                Func.RecordSet rslb = new Func.RecordSet(sql, con);
                sql = "Select * from FILE06A where EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "' ORDER BY SEQ_NO DESC";
                Func.RecordSet rse       = new Func.RecordSet(sql, con);
                DateTime       dtHienTai = T_String.GetDate();
                DateTime       dtKT      = T_String.GetDate();
                dtKT = Convert.ToDateTime(rslb.record(0, "LAB_ST"));
//					if((ck411==false && rslb.record(0,"LAB_NO") =="HDVTH" && rslb.rows>=1 && rse.rows>=0 && Convert.ToDateTime(rse.record(0,"LA1_ST"))<=dt6))
                if ((ck411 == false && rslb.rows >= 1 && rse.rows == 0 && rslb.record(0, "LAB_NO") == "HDVTH" && dtKT.AddYears(1) <= dt6) || (ck411 == false && rslb.rows >= 1 && rse.rows > 0 && Convert.ToDateTime(rse.record(0, "LA1_ED")) <= dt6))
                {
                    seqMax = T_String.GetMax("MAX(SEQ_NO)", "FILE06A", "EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "'");
                    nav.ToolBar_Click(new ToolBarButtonClickEventArgs(nav.cmd_add));
                    vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                    vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = rslb.record(0, "LAB_ID");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = rslb.record(0, "LAB_ST");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = rslb.record(0, "LAB_ED");
                    dt5 = Convert.ToDateTime(rslb.record(0, "LAB_ST"));
                    vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = dt5.AddYears(1).ToString("yyyy/MM/dd");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ED"] = dt5.AddYears(2).ToString("yyyy/MM/dd");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ED"] = Convert.ToDateTime(vs.Rows[vs.Rows.Count - 1]["LA1_ED"]).AddDays(-1).ToString("yyyy/MM/dd");

                    if (rse.rows > 0)
                    {
                        vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = rse.record(0, "LA1_ED");
                        vs.Rows[vs.Rows.Count - 1]["LA1_ED"] = Convert.ToDateTime(vs.Rows[vs.Rows.Count - 1]["LA1_ST"]).AddYears(1).ToString("yyyy/MM/dd");
                        vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = Convert.ToDateTime(vs.Rows[vs.Rows.Count - 1]["LA1_ST"]).AddDays(1).ToString("yyyy/MM/dd");
                    }

                    vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = dt1;
                    vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = LAB_NO;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = seqMax;
                    maxx++;
                    vs.Rows[vs.Rows.Count - 1][0] = vs.Rows.Count - 1;
                    for (int c = 1; c < vs1.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1][vs1.Cols[c].Name] = vs1.Rows[i][c];
                    }
                    for (int c = 1; c < vs2.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1]["SAL_N" + c] = vs2.Cols[c].Name;
                        vs.Rows[vs.Rows.Count - 1]["SAL_Q" + c] = vs2.Rows[1][c];
                    }
                    // LAB_ID
                    Func.RecordSet rs1 = new Func.RecordSet("Select * from FILE05A where LAB_NO=N'" + LAB_NO + "'", con);
                    if (rs1.rows > 0)
                    {
                        string LAB_ID = T_String.GetDataFromSQL("LAB_ID", "FILE05A", "LAB_NO=N'" + LAB_NO + "'");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_ID"] + "");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_I1"] + "");
                        if (LAB_ID.IndexOf("@") >= 0)
                        {
                            double vl = max + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                            vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                            string st = "000000000000";
                            max    = vl;
                            st     = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                            LAB_ID = LAB_ID.Replace("@", vl.ToString(st));
                        }
                        DateTime ngayky = DateTime.Parse(vs.Rows[vs.Rows.Count - 1]["LA1_ST"] + "");
                        LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yyyy") + "");
                        vs.Rows[vs.Rows.Count - 1]["LA1_ID"] = LAB_ID;

                        vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                        maxx++;
                    }
                    lb.Text   = ((int)(i * 100) / vs1.Rows.Count) + "% - " + vs1.Rows[i]["EMP_NM"];
                    pro.Value = (int)(i * 100) / vs1.Rows.Count;
                }
                //if(ck411==true && rslb.rows>=1 && Convert.ToDateTime(dt)<=dt6)
                if (ck411 == true && rslb.rows >= 1)
                {
                    seqMax = T_String.GetMax("MAX(SEQ_NO)", "FILE06A", "emp_id=N'" + vs1.Rows[i]["EMP_ID"] + "'");
                    nav.ToolBar_Click(new ToolBarButtonClickEventArgs(nav.cmd_add));
                    vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                    vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = rslb.record(0, "LAB_ID");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = rslb.record(0, "LAB_ST");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = rslb.record(0, "LAB_ED");
                    dt5 = Convert.ToDateTime(rslb.record(0, "LAB_ST"));
//						vs.Rows[vs.Rows.Count-1]["LA1_ST"]=dt5.AddYears(1).ToString("yyyy/MM/dd");
//						vs.Rows[vs.Rows.Count-1]["LA1_ED"]=dt5.AddYears(2).ToString("yyyy/MM/dd");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = dt;
                    vs.Rows[vs.Rows.Count - 1]["LA1_ED"] = Convert.ToDateTime(vs.Rows[vs.Rows.Count - 1]["LA1_ST"]).AddYears(1).ToString("yyyy/MM/dd");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ED"] = Convert.ToDateTime(vs.Rows[vs.Rows.Count - 1]["LA1_ED"]).AddDays(-1).ToString("yyyy/MM/dd");
//						if(rse.rows==0 && rslb.record(0,"LAB_NO")!="HDVTH")
//						{
//							vs.Rows[vs.Rows.Count-1]["LA1_ED"]=Convert.ToDateTime(vs.Rows[vs.Rows.Count-1]["LAB_ED"]).AddDays(+1).ToString("yyyy/MM/dd");
//						}
//						vs.Rows[vs.Rows.Count-1]["LA1_ED"]=Convert.ToDateTime(vs.Rows[vs.Rows.Count-1]["LA1_ED"]).AddDays(-1).ToString("yyyy/MM/dd");
//
//						vs.Rows[vs.Rows.Count-1]["LA1_ST"]=dt;
//
//						if(rse.rows>0)
//						{
//							vs.Rows[vs.Rows.Count-1]["LA1_ST"]=rse.record(0,"LA1_ED");
//							vs.Rows[vs.Rows.Count-1]["LA1_ED"]=Convert.ToDateTime(vs.Rows[vs.Rows.Count-1]["LA1_ST"]).AddYears(0).ToString("yyyy/MM/dd");
//							vs.Rows[vs.Rows.Count-1]["LA1_ST"]=dt;
//						}

                    vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = dt1;
                    vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = LAB_NO;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = seqMax;
                    maxx++;
                    vs.Rows[vs.Rows.Count - 1][0] = vs.Rows.Count - 1;
                    for (int c = 1; c < vs1.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1][vs1.Cols[c].Name] = vs1.Rows[i][c];
                    }
                    for (int c = 1; c < vs2.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1]["SAL_N" + c] = vs2.Cols[c].Name;
                        vs.Rows[vs.Rows.Count - 1]["SAL_Q" + c] = vs2.Rows[1][c];
                    }
                    Func.RecordSet rs1 = new Func.RecordSet("Select * from FILE05A where LAB_NO=N'" + LAB_NO + "'", con);
                    if (rs1.rows > 0)
                    {
                        string LAB_ID = T_String.GetDataFromSQL("LAB_ID", "FILE05A", "LAB_NO=N'" + LAB_NO + "'");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_ID"] + "");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_I1"] + "");
                        if (LAB_ID.IndexOf("@") >= 0)
                        {
                            double vl = max + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                            vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                            string st = "000000000000";
                            max    = vl;
                            st     = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                            LAB_ID = LAB_ID.Replace("@", vl.ToString(st));
                        }
                        DateTime ngayky = DateTime.Parse(vs.Rows[vs.Rows.Count - 1]["LAB_ST"] + "");
                        LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yyyy") + "");
                        vs.Rows[vs.Rows.Count - 1]["LA1_ID"] = LAB_ID;

                        vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                        maxx++;
                    }
                    lb.Text   = ((int)(i * 100) / vs1.Rows.Count) + "% - " + vs1.Rows[i]["EMP_NM"];
                    pro.Value = (int)(i * 100) / vs1.Rows.Count;
                }
            }

            vs.AutoSizeCols();
            pro.Value = 100;
            con.Close();
            this.Close();
            vs.Visible = true;
        }
Beispiel #22
0
        private void nav_TBarClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button.Equals(nav.cmd_add))
            {
                if (vs1.Row <= 0)
                {
                    return;
                }
                if (vs.Rows[vs.Rows.Count - 1].UserData + "" == "2")
                {
                    return;
                }
                nav.ToolBar_Click(e);
                vs.Rows[vs.Rows.Count - 1]["EMP_ID"] = vs1.Rows[vs1.Row]["EMP_ID"];
                int max = T_String.GetMax("MAX(SEQ_NO)", "FILC09A", "EMP_ID=N'" + vs1.Rows[vs1.Row]["EMP_ID"] + "'");
                vs.Rows[vs.Rows.Count - 1]["SEQ_NO"]     = max;
                vs.Rows[vs.Rows.Count - 1]["BLT_NM"]     = PublicFunction.A_UserID;
                vs.Rows[vs.Rows.Count - 1]["MAN_ST"]     = vs.Rows[vs.Rows.Count - 1]["MAN_ED"] =
                    vs.Rows[vs.Rows.Count - 1]["BLT_DT"] = T_String.GetDate().ToString("yyyy/MM/dd HH:mm");

                return;
            }
            if (e.Button.Equals(nav.cmd_save))
            {
//				if(vs1.Row<=0)
//					return;
                nav.ToolBar_Click(e);
//				int max=T_String.GetMax("MAX(SEQ_NO)","FILB06A","EMP_ID=N'"+vs1.Rows[vs1.Row]["EMP_ID"]+"'");
//				Func.RecordSet rs=new Func.RecordSet("Select * from FILB06A where EMP_ID=N'"+vs1.Rows[vs1.Row]["EMP_ID"]+"' and SEQ_NO="+(max-1),PublicFunction.C_con);
//				string sql="";
//				if(rs.rows>0)
//				{
//					sql="update FILB01A set ACC_NO=N'"+rs.record(0,"ACC_NO")+"',"
//						+"ACC_NM=N'"+rs.record(0,"ACC_NM")+"',"
//						+"BNK_NM=N'"+rs.record(0,"BNK_NM")+"' where EMP_ID=N'"+vs1.Rows[vs1.Row]["EMP_ID"]+"'";
//				}
//				else
//					sql="update FILB01A set ACC_NO=Default,ACC_NM=Default,BNK_NM=Default where EMP_ID=N'"+vs1.Rows[vs1.Row]["EMP_ID"]+"'";
//				PublicFunction.SQL_Execute(sql);
                return;
            }
            if (e.Button.Equals(nav.cmd_refresh))
            {
                if (nav.wh != "")
                {
                    nav.ToolBar_Click(e);
                }
                //else
                //nav.Show_VS("DEP_ID in "+T_String.DEP_ID(this.Tag));
                return;
            }
            if (e.Button.Equals(nav.cmd_search))
            {
                ArrayList a = new ArrayList();
                ArrayList b = new ArrayList();
                b.Add("MAN_ST");
                b.Add("MAN_ED");
                a.Add("EMP_ID");
                a.Add("EMP_I1");
                a.Add("EMP_NM");
                a.Add("POS_ID");
                a.Add("DEP_ID");

                frmSearch1 dlg = new frmSearch1(a, b, vs, nav);
                dlg.and = "and (DEP_ID in " + T_String.DEP_ID(this.Tag) + ")";
                dlg.ShowDialog();
            }
            nav.ToolBar_Click(e);
        }
Beispiel #23
0
        private void nav_TBarClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button.Equals(nav.cmd_add))
            {
                if (vs1.Row <= 0)
                {
                    return;
                }
                if (vs.Rows[vs.Rows.Count - 1].UserData + "" == "2")
                {
                    return;
                }
                nav.ToolBar_Click(e);
                vs.Rows[vs.Rows.Count - 1]["EMP_ID"] = vs1.Rows[vs1.Row]["EMP_ID"];
                int max = T_String.GetMax("MAX(SEQ_NO)", "FILB08A", "EMP_ID=N'" + vs1.Rows[vs1.Row]["EMP_ID"] + "'");
                vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = max;
                vs.Rows[vs.Rows.Count - 1]["BLT_NM"] = PublicFunction.A_UserID;
                vs.Rows[vs.Rows.Count - 1]["BLT_DT"] = T_String.GetDate().ToString("yyyy/MM/dd HH:mm");

                return;
            }
            if (e.Button.Equals(nav.cmd_save))
            {
                if (vs1.Row <= 0)
                {
                    return;
                }
                nav.ToolBar_Click(e);
                int            max = T_String.GetMax("MAX(SEQ_NO)", "FILB08A", "EMP_ID=N'" + vs1.Rows[vs1.Row]["EMP_ID"] + "'");
                Func.RecordSet rs  = new Func.RecordSet("Select * from FILB08A where EMP_ID=N'" + vs1.Rows[vs1.Row]["EMP_ID"] + "' and SEQ_NO=" + (max - 1), PublicFunction.C_con);
                string         sql = "";
                if (rs.rows > 0)
                {
                    sql = "update FILB01A set GRA_ID=N'" + rs.record(0, "GRA_ID") + "'"
                          + " where EMP_ID=N'" + vs1.Rows[vs1.Row]["EMP_ID"] + "'";
                }
//				else
//					sql="update FILB01A set ACC_NO=Default,ACC_NM=Default,BNK_NM=Default where EMP_ID=N'"+vs1.Rows[vs1.Row]["EMP_ID"]+"'";
                PublicFunction.SQL_Execute(sql);
                return;
            }
            if (e.Button.Equals(nav.cmd_refresh))
            {
                if (nav.wh != "")
                {
                    nav.ToolBar_Click(e);
                }
                return;
            }
            if (e.Button.Equals(nav.cmd_delete))
            {
                Func.RecordSet rs = new Func.RecordSet("Select * from FILB01A where EMP_ID=N'" + vs1.Rows[vs1.Row]["EMP_ID"] + "' and GRA_ID='" + vs.Rows[vs.Row]["GRA_ID"] + "'", PublicFunction.C_con);

                if (rs.rows <= 0)
                {
                    nav.ToolBar_Click(e);
                }
                else
                {
                    MessageBox.Show("Can not delete this row!!");
                }
                return;
            }
            nav.ToolBar_Click(e);
        }
        private void show()
        {
            double seqMax = 0;

            vs.Visible = false;
            string        sql = "", sql1 = "";
            SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            double maxx = T_String.GetMax("MAX(SEQ_N2)", "FILE06A");
            double max  = T_String.GetMax("MAX(SEQ_N1)", "FILE06A", "LAB_NO=N'" + LAB_NO + "'") - 1;

            for (int i = 1; i < vs1.Rows.Count; i++)
            {
                sql = "Select * from FILE03A where LAB_NO NOT LIKE 'HDTV%'AND LAB_NO NOT LIKE 'TTTV%' and EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "'"
                      + " AND LAB_ST>=(SELECT CONVERT(NVARCHAR,INH_DT,111) FROM FILB01A WHERE EMP_ID='" + vs1.Rows[i]["EMP_ID"] + "')"
                      + " AND LAB_ST<'" + DateTime.Parse(dt).ToString("yyyy/MM/dd") + "'"
                      + " AND (ISNULL(LIM_NO,0)=1 OR (ISNULL(LIM_NO,0)=0 AND LAB_ED>'" + DateTime.Parse(dt).ToString("yyyy/MM/dd") + "'))"
                      + " ORDER BY LAB_ST DESC";
                Func.RecordSet rslb = new Func.RecordSet(sql, con);
                sql1 = "Select top 1 * from FILE06A where EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "' ORDER BY LA1_SG DESC";
                Func.RecordSet rslb1 = new Func.RecordSet(sql1, con);
                if (rslb.rows > 0)
                {
                    seqMax = T_String.GetMax("MAX(SEQ_NO)", "FILE06A", "emp_id=N'" + vs1.Rows[i]["EMP_ID"] + "'");
                    nav.ToolBar_Click(new ToolBarButtonClickEventArgs(nav.cmd_add));
                    vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                    vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = rslb.record(0, "LAB_ID");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = rslb.record(0, "LAB_ST");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = rslb.record(0, "LAB_ED");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = dt;
                    vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = dt1;
                    if (PublicFunction.CUS_ID == "43")                 //cty ASTRO
                    {
                        if (rslb1.rows == 0)
                        {
                            vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = Convert.ToDateTime(rslb.record(0, "LAB_ST")).AddYears(2);
                            vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = Convert.ToDateTime(rslb.record(0, "LAB_ST")).AddYears(2);
                        }
                        if (rslb1.rows > 0)
                        {
                            vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = Convert.ToDateTime(rslb1.record(0, "LA1_ST")).AddYears(1);
                            vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = Convert.ToDateTime(rslb1.record(0, "LA1_ST")).AddYears(1);
                        }
                    }
                    vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = LAB_NO;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = seqMax;
                    maxx++;
                    vs.Rows[vs.Rows.Count - 1][0] = vs.Rows.Count - 1;
                    for (int c = 1; c < vs1.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1][vs1.Cols[c].Name] = vs1.Rows[i][c];
                    }
                    for (int c = 1; c < vs2.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1]["SAL_N" + c] = vs2.Cols[c].Name;
                        vs.Rows[vs.Rows.Count - 1]["SAL_Q" + c] = vs2.Rows[1][c];
                    }

                    // LAB_ID
                    Func.RecordSet rs1 = new Func.RecordSet("Select * from FILE05A where LAB_NO=N'" + LAB_NO + "'", con);
                    if (rs1.rows > 0)
                    {
                        string LAB_ID = T_String.GetDataFromSQL("LAB_ID", "FILE05A", "LAB_NO=N'" + LAB_NO + "'");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_ID"] + "");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_I1"] + "");
                        if (LAB_ID.IndexOf("@") >= 0)
                        {
                            double vl = max + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                            vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                            string st = "000000000000";
                            max    = vl;
                            st     = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                            LAB_ID = LAB_ID.Replace("@", vl.ToString(st));
                        }
                        //THEM CHUC NANG GIONG BEN HDLD
                        DateTime ngayky = DateTime.Parse(dt);
                        if (PublicFunction.CUS_ID == "44")                       //Leeshin
                        {
                            LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yy") + "");
                        }
                        else
                        {
                            LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yyyy") + "");
                        }
                        LAB_ID = LAB_ID.Replace("*(Month)", ngayky.ToString("MM") + "");
                        LAB_ID = LAB_ID.Replace("*(Day)", ngayky.ToString("dd") + "");
                        //lay so lan ki
                        int count = 0;
                        if (PublicFunction.CUS_ID == "44")                       //Leeshin lay so lan ki theo loai hop dong
                        {
                            count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE06A", "EMP_ID=N'" + vs1.Rows[i]["EMP_ID"]
                                                                               + "' AND LAB_NO ='" + LAB_NO + "' and LA1_ST>=(SELECT CONVERT(NVARCHAR,INH_DT,111) INH_DT FROM FILB01A "
                                                                               + " WHERE EMP_ID='" + vs1.Rows[i]["EMP_ID"] + "')"));
                        }
                        else
                        {
                            count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE06A", "EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "'"));
                        }
                        LAB_ID = LAB_ID.Replace("*(Count)", (count + 1) + "");
                        vs.Rows[vs.Rows.Count - 1]["LA1_ID"] = LAB_ID;
                    }


                    lb.Text   = ((int)(i * 100) / vs1.Rows.Count) + "% - " + vs1.Rows[i]["EMP_NM"];
                    pro.Value = (int)(i * 100) / vs1.Rows.Count;
                }
            }
            vs.AutoSizeCols();
            pro.Value = 100;
            con.Close();
            this.Close();
            vs.Visible = true;
        }
        private void show()
        {
            double seqMax = 0;

            vs.Visible = false;
            string        sql = "";
            SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            double maxx = T_String.GetMax("MAX(SEQ_N2)", "FILE06A");
            double max  = T_String.GetMax("MAX(SEQ_N1)", "FILE06A", "LAB_NO=N'" + LAB_NO + "'") - 1;

            for (int i = 1; i < vs1.Rows.Count; i++)
            {
                sql = "Select * from FILE03A where EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "' ORDER BY LAB_ST DESC";
                Func.RecordSet rslb = new Func.RecordSet(sql, con);
                if (rslb.rows > 0)
                {
                    seqMax = T_String.GetMax("MAX(SEQ_NO)", "FILE06A", "emp_id=N'" + vs1.Rows[i]["EMP_ID"] + "'");
                    nav.ToolBar_Click(new ToolBarButtonClickEventArgs(nav.cmd_add));
                    vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                    vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = rslb.record(0, "LAB_ID");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = rslb.record(0, "LAB_ST");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = rslb.record(0, "LAB_ED");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = dt;
                    vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = dt1;
                    vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = LAB_NO;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = seqMax;
                    maxx++;
                    vs.Rows[vs.Rows.Count - 1][0] = vs.Rows.Count - 1;
                    for (int c = 1; c < vs1.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1][vs1.Cols[c].Name] = vs1.Rows[i][c];
                    }
                    for (int c = 1; c < vs2.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1]["SAL_N" + c] = vs2.Cols[c].Name;
                        vs.Rows[vs.Rows.Count - 1]["SAL_Q" + c] = vs2.Rows[1][c];
                    }

                    // LAB_ID
                    Func.RecordSet rs1 = new Func.RecordSet("Select * from FILE05A where LAB_NO=N'" + LAB_NO + "'", con);
                    if (rs1.rows > 0)
                    {
                        string LAB_ID = T_String.GetDataFromSQL("LAB_ID", "FILE05A", "LAB_NO=N'" + LAB_NO + "'");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_ID"] + "");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_I1"] + "");
                        if (LAB_ID.IndexOf("@") >= 0)
                        {
                            double vl = max + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                            vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                            string st = "000000000000";
                            max    = vl;
                            st     = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                            LAB_ID = LAB_ID.Replace("@", vl.ToString(st));
                        }
                        vs.Rows[vs.Rows.Count - 1]["LA1_ID"] = LAB_ID;
                    }


                    lb.Text   = ((int)(i * 100) / vs1.Rows.Count) + "% - " + vs1.Rows[i]["EMP_NM"];
                    pro.Value = (int)(i * 100) / vs1.Rows.Count;
                }
            }
            vs.AutoSizeCols();
            pro.Value = 100;
            con.Close();
            this.Close();
            vs.Visible = true;
        }
Beispiel #26
0
        private void nav_TBarClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button.Equals(nav.cmd_add))
            {
                if (vs.Rows.Count == 1 || (int)vs.Rows[vs.Rows.Count - 1].UserData != 2)
                {
                    nav.ToolBar_Click(e);
                }
                vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] = "M" + T_String.GetMax("MAX(cast(right(MEAL_ID,3) AS int))", "FILA20A").ToString("000");
                return;
            }
            if (e.Button.Equals(nav.cmd_save))
            {
                SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                try
                {
                    string sql = "if not exists (select * from syscolumns where id=object_id('FILC15A') and name='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "') ALTER TABLE FILC15A ADD " + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + " bit NULL";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "if not exists (select * from syscolumns where id=object_id('FILC06AA') and name='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "') ALTER TABLE FILC06AA ADD " + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + " int NULL";
                    PublicFunction.SQL_Execute(sql, con);

                    int max = T_String.GetMax("MAX(ID1)", "SYS_SQL_SELECT", "ID=N'frmTaDailyMeal_vs'");
                    sql = "delete from SYS_SQL_SELECT where ID=N'frmTaDailyMeal_vs' and FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into SYS_SQL_SELECT(ID,ID1,NAME,FIELD,SHOW,SEQ) values('frmTaDailyMeal_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "',1,'" + max + "')";
                    PublicFunction.SQL_Execute(sql, con);

                    max = T_String.GetMax("MAX(ID)", "SYS_LABEL_VS", "NAME=N'frmTaDailyMeal_vs'");
                    sql = "delete from SYS_LABEL_VS where NAME=N'frmTaDailyMeal_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into SYS_LABEL_VS(NAME,ID,EN,CH,VN,TT,FNAME) values('frmTaDailyMeal_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "')";
                    PublicFunction.SQL_Execute(sql, con);

                    max = T_String.GetMax("MAX(ID1)", "GP_SYS_SQL_SELECT", "ID=N'frmTaMonthAddUp000_vs'");
                    sql = "delete from GP_SYS_SQL_SELECT where ID=N'frmTaMonthAddUp000_vs' and FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into GP_SYS_SQL_SELECT(ID,ID1,NAME,FIELD,SHOW,SEQ) values('frmTaMonthAddUp000_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "',1,'" + max + "')";
                    PublicFunction.SQL_Execute(sql, con);

                    max = T_String.GetMax("MAX(ID1)", "GP_SYS_SQL_SELECT", "ID=N'frmTaMonthAddUp001_vs'");
                    sql = "delete from GP_SYS_SQL_SELECT where ID=N'frmTaMonthAddUp001_vs' and  FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into GP_SYS_SQL_SELECT(ID,ID1,NAME,FIELD,SHOW,SEQ) values('frmTaMonthAddUp001_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "',1,'" + max + "')";
                    PublicFunction.SQL_Execute(sql, con);

                    max = T_String.GetMax("MAX(ID1)", "GP_SYS_SQL_SELECT", "ID=N'frmTaMonthAddUp002_vs'");
                    sql = "delete from GP_SYS_SQL_SELECT where ID=N'frmTaMonthAddUp002_vs' and FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into GP_SYS_SQL_SELECT(ID,ID1,NAME,FIELD,SHOW,SEQ) values('frmTaMonthAddUp002_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "',1,'" + max + "')";
                    PublicFunction.SQL_Execute(sql, con);

                    max = T_String.GetMax("MAX(ID1)", "GP_SYS_SQL_SELECT", "ID=N'frmTaMonthAddUp003_vs'");
                    sql = "delete from GP_SYS_SQL_SELECT where ID=N'frmTaMonthAddUp003_vs' and  FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into GP_SYS_SQL_SELECT(ID,ID1,NAME,FIELD,SHOW,SEQ) values('frmTaMonthAddUp003_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "',1,'" + max + "')";
                    PublicFunction.SQL_Execute(sql, con);

                    max = T_String.GetMax("MAX(ID1)", "GP_SYS_SQL_SELECT", "ID=N'frmTaMonthAddUp004_vs'");
                    sql = "delete from GP_SYS_SQL_SELECT where ID=N'frmTaMonthAddUp004_vs' and  FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into GP_SYS_SQL_SELECT(ID,ID1,NAME,FIELD,SHOW,SEQ) values('frmTaMonthAddUp004_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "',1,'" + max + "')";
                    PublicFunction.SQL_Execute(sql, con);

                    max = T_String.GetMax("MAX(ID)", "SYS_LABEL_VS_ATT", "NAME=N'frmTaMonthAddUp000_vs'");
                    sql = "delete from SYS_LABEL_VS_ATT where NAME=N'frmTaMonthAddUp000_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into SYS_LABEL_VS_ATT(NAME,ID,EN,CH,VN,TT,FNAME) values('frmTaMonthAddUp000_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "')";
                    PublicFunction.SQL_Execute(sql, con);

                    max = T_String.GetMax("MAX(ID)", "SYS_LABEL_VS_ATT", "NAME=N'frmTaMonthAddUp001_vs'");
                    sql = "delete from SYS_LABEL_VS_ATT where NAME=N'frmTaMonthAddUp001_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into SYS_LABEL_VS_ATT(NAME,ID,EN,CH,VN,TT,FNAME) values('frmTaMonthAddUp001_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "')";
                    PublicFunction.SQL_Execute(sql, con);

                    max = T_String.GetMax("MAX(ID)", "SYS_LABEL_VS_ATT", "NAME=N'frmTaMonthAddUp002_vs'");
                    sql = "delete from SYS_LABEL_VS_ATT where NAME=N'frmTaMonthAddUp002_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into SYS_LABEL_VS_ATT(NAME,ID,EN,CH,VN,TT,FNAME) values('frmTaMonthAddUp002_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "')";
                    PublicFunction.SQL_Execute(sql, con);

                    max = T_String.GetMax("MAX(ID)", "SYS_LABEL_VS_ATT", "NAME=N'frmTaMonthAddUp003_vs'");
                    sql = "delete from SYS_LABEL_VS_ATT where NAME=N'frmTaMonthAddUp003_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into SYS_LABEL_VS_ATT(NAME,ID,EN,CH,VN,TT,FNAME) values('frmTaMonthAddUp003_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "')";
                    PublicFunction.SQL_Execute(sql, con);

                    max = T_String.GetMax("MAX(ID)", "SYS_LABEL_VS_ATT", "NAME=N'frmTaMonthAddUp004_vs'");
                    sql = "delete from SYS_LABEL_VS_ATT where NAME=N'frmTaMonthAddUp004_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                    sql = "Insert into SYS_LABEL_VS_ATT(NAME,ID,EN,CH,VN,TT,FNAME) values('frmTaMonthAddUp004_vs','" + max + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "','" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "')";
                    PublicFunction.SQL_Execute(sql, con);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            if (e.Button.Equals(nav.cmd_delete))
            {
                SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                try
                {
                    string sql = "if exists (select * from syscolumns where id=object_id('FILC15A') and name='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "') ALTER TABLE FILC15A DROP COLUMN " + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "if exists (select * from syscolumns where id=object_id('FILC06AA') and name='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "') ALTER TABLE FILC06AA DROP COLUMN " + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from SYS_SQL_SELECT where ID=N'frmTaDailyMeal_vs' and FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from SYS_LABEL_VS where NAME=N'frmTaDailyMeal_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from GP_SYS_SQL_SELECT where ID=N'frmTaMonthAddUp000_vs' and FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from GP_SYS_SQL_SELECT where ID=N'frmTaMonthAddUp001_vs' and FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from GP_SYS_SQL_SELECT where ID=N'frmTaMonthAddUp002_vs' and FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from GP_SYS_SQL_SELECT where ID=N'frmTaMonthAddUp003_vs' and FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from GP_SYS_SQL_SELECT where ID=N'frmTaMonthAddUp004_vs' and FIELD='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from SYS_LABEL_VS_ATT where NAME=N'frmTaMonthAddUp000_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from SYS_LABEL_VS_ATT where NAME=N'frmTaMonthAddUp001_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from SYS_LABEL_VS_ATT where NAME=N'frmTaMonthAddUp002_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from SYS_LABEL_VS_ATT where NAME=N'frmTaMonthAddUp003_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);

                    sql = "delete from SYS_LABEL_VS_ATT where NAME=N'frmTaMonthAddUp004_vs' and FNAME='" + vs.Rows[vs.Rows.Count - 1]["MEAL_ID"] + "'";
                    PublicFunction.SQL_Execute(sql, con);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            nav.ToolBar_Click(e);
        }
Beispiel #27
0
        private void show()
        {
            vs.Visible = false;
            SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            string sql = "";

            sql = "Select * from FILE01A ";
            Func.RecordSet rs2 = new Func.RecordSet(sql, con);
            ArrayList      a   = new ArrayList();
            ArrayList      b   = new ArrayList();

            for (int i = 0; i < rs2.rows; i++)
            {
                a.Add(rs2.record(i, "LAB_NO"));
                int tam = T_String.IsNullTo0(T_String.GetDataFromSQL("MAX(SEQ_N1)", "FILE03A", "LAB_NO=N'" + rs2.record(i, "LAB_NO") + "'"));
                if (tam == 1)
                {
                    tam = T_String.IsNullTo0(rs2.record(i, "STT_N2") + "");
                }
                b.Add(tam);
            }
            double maxx = T_String.GetMax("MAX(SEQ_N2)", "FILE03A");

            sql = "Select EMP_ID,EMP_I1,EMP_NM,INH_DT,TYP_ID,POS_ID,DEP_ID from FILB01A where (VAC_BT is null or VAC_BT=0)";
            if (NEW_BT)
            {
                sql = sql + " and isnull(NEW_BT,0)=1 and isnull(LCK_BT,0)=0";
            }
            if (wh != "")
            {
                sql += " and " + wh;
            }
            DateTime dt1 = T_String.GetDate();

            dt1 = dt1.AddDays(T_String.IsNullTo0(day));
            DateTime NgayBD     = T_String.GetDate();
            DateTime NgayVaoLam = T_String.GetDate();

            //-------------------
            if (PublicFunction.CUS_ID == "43")         //cty ASTRO
            {
                SqlConnection con1 = new SqlConnection(PublicFunction.C_con.ConnectionString);
                if (con1.State == ConnectionState.Closed)
                {
                    con1.Open();
                }
                string sql1 = "";
                sql1 = "Select * from FILB01A";
                if (wh != "")
                {
                    sql1 += " where " + wh;
                }
                Func.RecordSet rs3 = new Func.RecordSet(sql1, con1);
                if (rs3.rows > 0)
                {
                    NgayVaoLam = DateTime.Parse(rs3.record(0, "INH_DT"));
                }
                if (NgayVaoLam.Day >= 1 & NgayVaoLam.Day <= 20)
                {
                    NgayBD = new DateTime(NgayVaoLam.Year, NgayVaoLam.Month, 1);
                    NgayBD = NgayBD.AddMonths(1);
                }
                if (NgayVaoLam.Day >= 21 & NgayVaoLam.Day <= 31)
                {
                    NgayBD = new DateTime(NgayVaoLam.Year, NgayVaoLam.Month, 1);
                    NgayBD = NgayBD.AddMonths(2);
                }
                sql += " and '" + dt1.ToString("yyyy/MM/dd") + "'>='" + NgayBD.ToString("yyyy/MM/dd") + "' and EMP_ID not in(Select Distinct EMP_ID from FILE03A where LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                       + "' or LIM_NO=1)";
            }
            //-------------------
            ////luan rem de khi in roi van hien ra
            if (PublicFunction.CUS_ID != "43")
            {
                if (PublicFunction.CUS_ID == "44")               //LeeShin ki lai tu dau cho nguoi di lam lai
                {
                    sql += " and EMP_ID not in(Select Distinct EMP_ID from FILE03A where (LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                           + "' and LAB_ST>=(SELECT CONVERT(NVARCHAR,INH_DT,111) FROM FILB01A WHERE FILB01A.EMP_ID=FILE03A.EMP_ID)) "
                           + "or ( LIM_NO=1 and LAB_ST>=(SELECT CONVERT(NVARCHAR,INH_DT,111) FROM FILB01A WHERE FILB01A.EMP_ID=FILE03A.EMP_ID) ))";
                }
                else if (PublicFunction.CUS_ID == "52")               //domex quang nam, in HDLD lan dau cung thoi diem voi HDTV
                {
                    sql += " and EMP_ID not in(Select Distinct EMP_ID from FILE03A where (LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                           + "' and LAB_NO NOT LIKE 'HDTV%') or LIM_NO=1)";
                }
                else if (PublicFunction.CUS_ID == "53")               // Omexey, ko ki HD cho nv TQ và Cam
                {
                    sql += " and EMP_ID not in(Select Distinct EMP_ID from FILE03A where LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                           + "' or LIM_NO=1) and COU_ID<>'6' and COU_ID<>'10' and COU_ID<>'12'";
                }
                else
                {
                    sql += " and EMP_ID not in(Select Distinct EMP_ID from FILE03A where LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                           + "' or LIM_NO=1)";
                }
            }
            vs.Rows.Count = 1;
            Func.RecordSet rs = new Func.RecordSet(sql, con);
            for (int i = 0; i < rs.rows; i++)
            {
                try
                {
                    sql = "Select * from FILE03A where EMP_ID=N'" + rs.record(i, "EMP_ID") + "' ORDER BY LAB_ST DESC,LAB_ED DESC";
                    if (PublicFunction.CUS_ID == "44")                 //LeeShin
                    {
                        sql = "Select FILE03A.* from FILE03A INNER JOIN FILB01A ON FILE03A.EMP_ID=FILB01A.EMP_ID where FILE03A.EMP_ID=N'" + rs.record(i, "EMP_ID")
                              + "' AND LAB_ST>=INH_DT ORDER BY LAB_ST DESC";
                    }
                    Func.RecordSet rslb = new Func.RecordSet(sql, con);
                    DateTime       dt;
                    int            max;
                    if (rslb.rows == 0)
                    {
                        dt = DateTime.Parse(rs.record(i, "INH_DT"));
                        if (PublicFunction.CUS_ID == "43")                     //cty ASTRO
                        {
                            dt = NgayBD;
                        }
                        max = 1;
                    }
                    else
                    {
                        dt = DateTime.Parse(rslb.record(0, "LAB_ED"));
                        dt = dt.AddDays(1);
                        if (PublicFunction.CUS_ID == "44" || PublicFunction.CUS_ID == "53")                   //LEESHIN LAY NGAY BD KI HD SAU KHI THU VIEC LA NGAY 1 TAY
                        {
                            if (rslb.record(0, "LAB_NO") == "HDTV1" || rslb.record(0, "LAB_NO") == "HDTV2" || rslb.record(0, "LAB_NO") == "HDTV")
                            {
                                dt = DateTime.Parse(rslb.record(0, "LAB_ED"));
                                if (dt.Day > 15)
                                {
                                    dt = dt.AddMonths(1);
                                }
                                dt = DateTime.Parse(dt.ToString("yyyy/MM") + "/01");
                            }
                        }
                        if (PublicFunction.CUS_ID == "52")                     //Domex Quang Nam
                        {
                            if (rslb.record(0, "LAB_NO") == "HDTV2" || rslb.record(0, "LAB_NO") == "HDTV1" || rslb.record(0, "LAB_NO") == "HDTV6")
                            {
                                dt = DateTime.Parse(rslb.record(0, "LAB_ST"));
                            }
                        }
                        max = 1 + T_String.IsNullTo0(rslb.record(0, "SEQ_NO"));
                    }
//					if(ngaytinh>0)//ngaytinh
//					{
//						if(dt.Day<ngaytinh)
//							dt=new DateTime (dt.Year,dt.Month,1);
//						else
//						{
//							dt=dt.AddMonths(1);
//							dt=new DateTime (dt.Year,dt.Month,1);
//						}
//					}
                    if (LAB_N1 != "")
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and a.LAB_NO=N'" + LAB_N1 + "' and a.LAB_NO=b.LAB_NO";
                    }
                    else
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and SEQ_NO=" + max + " and a.LAB_NO=b.LAB_NO";
                    }
                    Func.RecordSet rs1 = new Func.RecordSet(sql, con);
                    if (rs1.rows == 0)
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and REP_BT=1 and a.LAB_NO=b.LAB_NO";
                        rs1 = new Func.RecordSet(sql, con);
                    }
                    try
                    {
                        if (rs1.rows > 0 && rs1.record(0, "LAB_ID") + "" != "" && (this.LAB_NO == "" || this.LAB_NO == rs1.record(0, "LAB_NO")))
                        {
                            vs.Rows.Count++;
                            vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                            vs.Rows[vs.Rows.Count - 1][0]        = vs.Rows.Count - 1;
                            vs.Rows[vs.Rows.Count - 1]["EMP_ID"] = rs.record(i, "EMP_ID");
                            vs.Rows[vs.Rows.Count - 1]["EMP_I1"] = rs.record(i, "EMP_I1");
                            vs.Rows[vs.Rows.Count - 1]["EMP_NM"] = rs.record(i, "EMP_NM");
                            vs.Rows[vs.Rows.Count - 1]["TYP_ID"] = rs.record(i, "TYP_ID");
                            vs.Rows[vs.Rows.Count - 1]["POS_ID"] = rs.record(i, "POS_ID");
                            vs.Rows[vs.Rows.Count - 1]["DEP_ID"] = rs.record(i, "DEP_ID");
                            vs.Rows[vs.Rows.Count - 1]["INH_DT"] = rs.record(i, "INH_DT");
                            vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = rs1.record(0, "SEQ_NO");
                            if (date != "")
                            {
                                vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = date;
                                dt = DateTime.Parse(date);
                            }
                            else
                            {
                                vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = dt.ToString("yyyy/MM/dd");
                            }

                            if (rs1.record(0, "LIM_NO") + "" == "True")
                            {
                                vs.Rows[vs.Rows.Count - 1]["LIM_NO"] = "True";
                            }
                            else
                            {
                                if (PublicFunction.CUS_ID == "22" && rs1.record(0, "LAB_NO") == "HDHV")                           //xet TH HDTV 6 ngay cho DM
                                {
                                    //dt=DateTime.Parse(rslb.record(0,"LAB_ST"));
                                    int id = 0;
                                    while (id < 27)
                                    {
//										string data=T_String.GetDataFromSQL("h"+dt.Day,"FILA16A","YYY_YY="+dt.Year+" and MMM_MM="+dt.Month);
//										if(dt.DayOfWeek!=DayOfWeek.Sunday && (data+""=="False" || data==null ))
//										{
//											id++;
//
//										}
                                        id++;
                                        dt = dt.AddDays(1);
                                    }
                                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.ToString("yyyy/MM/dd");
                                }
                                else
                                {
                                    if (rs1.record(0, "YYY_YY") + "" != "")
                                    {
                                        dt = dt.AddYears(T_String.IsNullTo0(rs1.record(0, "YYY_YY") + ""));
                                    }
                                    else
                                    {
                                        dt = dt.AddMonths(T_String.IsNullTo0(rs1.record(0, "MMM_MM") + ""));
                                    }
                                    if (ngaytinh > 0)                                 //ngaytinh
                                    {
                                        if (dt.Day < ngaytinh)
                                        {
                                            dt = new DateTime(dt.Year, dt.Month, 1);
                                        }
                                        else
                                        {
                                            dt = dt.AddMonths(1);
                                            dt = new DateTime(dt.Year, dt.Month, 1);
                                        }
                                    }
                                    if (ngaytru)
                                    {
                                        vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.AddDays(-1).ToString("yyyy/MM/dd");
                                    }
                                    else
                                    {
                                        vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.ToString("yyyy/MM/dd");
                                    }
                                    if (PublicFunction.CUS_ID == "43")
                                    {
                                        vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.AddDays(-1).ToString("yyyy/MM/dd");
                                    }
                                }
                            }
                            vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = rs1.record(0, "LAB_NO");
                            vs.Rows[vs.Rows.Count - 1]["LAB_TP"] = rs1.record(0, "LAB_TP");
                            // LAB_ID  ma so hop dong
                            string LAB_ID = rs1.record(0, "LAB_ID");
                            LAB_ID = LAB_ID.Replace("#", rs.record(i, "EMP_ID") + "");
                            LAB_ID = LAB_ID.Replace("&", rs.record(i, "EMP_I1") + "");
                            if (LAB_ID.IndexOf("@") >= 0)
                            {
                                int index = a.IndexOf(rs1.record(0, "LAB_NO"));
                                int vl    = T_String.IsNullTo0(b[index] + "") + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                                vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                                string st = "000000000000";
                                b[index] = vl;
                                st       = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                                LAB_ID   = LAB_ID.Replace("@", vl.ToString(st));
                            }

                            DateTime ngayky = DateTime.Parse(vs.Rows[vs.Rows.Count - 1]["LAB_ST"] + "");
                            if (PublicFunction.CUS_ID == "44")                           //Leeshin
                            {
                                LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yy") + "");
                            }
                            else
                            {
                                LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yyyy") + "");
                            }
                            LAB_ID = LAB_ID.Replace("*(Month)", ngayky.ToString("MM") + "");
                            LAB_ID = LAB_ID.Replace("*(Day)", ngayky.ToString("dd") + "");
                            //lay so lan ki
                            int count = 0;
                            if (PublicFunction.CUS_ID == "44")                           //Leeshin lay so lan ki theo loai hop dong
                            {
                                if (rs1.record(0, "LAB_NO") == "HDTV1" || rs1.record(0, "LAB_NO") == "HDTV2")
                                {
                                    count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE03A", "EMP_ID=N'" + rs.record(i, "EMP_ID") + "' AND LAB_NO like 'HDTV%'"));
                                }
                                else
                                {
                                    count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE03A", "EMP_ID=N'" + rs.record(i, "EMP_ID") + "' AND LAB_NO<>'HDTV'"));
                                }
                            }
                            else
                            {
                                count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE03A", "EMP_ID=N'" + rs.record(i, "EMP_ID") + "'"));
                            }
                            LAB_ID = LAB_ID.Replace("*(Count)", (count + 1) + "");
                            LAB_ID = LAB_ID.Replace("*(DEP)", rs.record(i, "DEP_ID") + "");
                            LAB_ID = LAB_ID.Replace("*(POS)", rs.record(i, "POS_ID") + "");
                            LAB_ID = LAB_ID.Replace("*(NATURE)", rs.record(i, "TYP_ID") + "");



                            ////////////
                            vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = LAB_ID;

                            vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                            maxx++;
                        }
                    }
                    catch (Exception ex) { MessageBox.Show(ex.Message); vs.Rows.Count--; }
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                lb.Text   = ((int)(i * 100) / rs.rows) + "% - " + rs.record(i, "EMP_NM");
                pro.Value = (int)(i * 100) / rs.rows;
            }
            vs.AutoSizeCols();
            pro.Value = 100;
            con.Close();
            this.Close();
            vs.Visible = true;
        }