private void btnSave_Click(object sender, EventArgs e)
        {
            if (fncBlank())
            {
                return;
            }

            ArrayList arQuery = new ArrayList();

            GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection();
            string sqlQuery = "";
            Int32  NewId    = 0;

            string sqlQuery1 = "";
            Int64  ChkLock   = 0;


            sqlQuery1 = "Select dbo.fncProcessLock (" + Common.Classes.clsMain.intComId + ", 'Casual Attend Lock','" + clsProc.GTRDate(dtFromDate.Value.ToString()) + "')";
            ChkLock   = clsCon.GTRCountingDataLarge(sqlQuery1);


            if (ChkLock == 1)
            {
                MessageBox.Show("Process Lock. Please communicate with Administrator.");
                return;
            }


            try
            {
                {
                    //add new
                    //sqlQuery = "Select Isnull(Max(advID),0)+1 As NewId from tblSal_Adv";
                    //NewId = clsCon.GTRCountingData(sqlQuery);

                    DateTime dt1 = dtFromDate.DateTime;
                    DateTime dt2 = dtLast.DateTime;

                    TimeSpan ts = dt1 - dt2;

                    int days = ts.Days;

                    if (days > 1)
                    {
                        MessageBox.Show("Please Run The Process For " + clsProc.GTRDate(dtLast.DateTime.AddDays(1).ToString()) + " ");
                        dtFromDate.Focus();
                        dtFromDate.Value = (dtLast.DateTime.AddDays(1));
                    }


                    if (chkMonthly.Checked == true)
                    {
                        //int ICount  = 0; /// For the Process PrDate Count
                        //int ICount2 = 0; ///' For the Process PrDate Count

                        int Y = 0, X = 0;
                        //double Z = 1;

                        X = dtFromDate.DateTime.Day;
                        Y = dtToDate.DateTime.Day;

                        while (X <= Y)
                        {
                            lblProcess.Text = "Processing " + clsProc.GTRDate(dtLast.DateTime.ToString()) + " .....";

                            dsDetails = new System.Data.DataSet();

                            {
                                sqlQuery = "Exec prcProcessAttendCasual " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtFromDate.Value.ToString()) + "'";
                                int i = clsCon.GTRSaveDataWithSQLCommand(sqlQuery);

                                //sqlQuery = "Exec prcProcessAttendShift " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtFromDate.Value.ToString()) + "'";
                                //clsCon.GTRFillDatasetWithSQLCommand(ref dsDetails, sqlQuery);


                                //dsDetails.Tables[0].TableName = "tblSalAdv";
                            }

                            dtFromDate.Value = dtFromDate.DateTime.AddDays(1);

                            X++;
                            //Z++;
                        }

                        //'            Call DaySelector
                        //        Call Praram
                        //        CON.Execute "PrProcessAtt '" & AmzDate(DTPicker1.value) & "'"
                        //        CON.Execute "BuyerJobcardPrint '" & AmzDate(DTPicker1.value) & "'"
                        //        'If RSCounter(rspcs2) = 0 Then

                        //                            Call Connect
                        //                                ICount2 = TotalRecord("tblPrDate", "PrDate", AmzDate(DTPicker1.value))
                        //                                If ICount2 < 1 Then
                        //                                    CON.Execute "insert tblPrDate Values ('" & AmzDate(DTPicker1.value) & "')"
                        //                                End If
                        //        'Call ProcessAtt(0)
                        //    End If
                        //         Next
                    }
                    else
                    {
                        lblProcess.Text = "Processing " + clsProc.GTRDate(dtLast.DateTime.ToString()) + " .....";

                        dsDetails = new System.Data.DataSet();

                        {
                            if (OptSts.Value == "H" || OptSts.Value == "R" || OptSts.Value == "W")
                            {
                                sqlQuery = "delete tblProssType where ProssDt =  '" + clsProc.GTRDate(dtFromDate.Value.ToString()) + "';   insert into tblProssType(ProssDt,DaySts,DayStsB,IsLock) values ('" + clsProc.GTRDate(dtFromDate.Value.ToString()) + "','" + (OptSts.Value.ToString()) + "','" + (OptSts.Value.ToString()) + "',0)";
                                clsCon.GTRFillDatasetWithSQLCommand(ref dsDetails, sqlQuery);
                            }


                            sqlQuery = "Exec prcProcessAttendCasual " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtFromDate.Value.ToString()) + "'";
                            int i = clsCon.GTRSaveDataWithSQLCommand(sqlQuery);
                        }
                    }
                    MessageBox.Show("Process complete");
                }
                prcClearData();
                //cboEmpID.Focus();

                prcLoadList();
                prcLoadCombo();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                arQuery = null;
                clsCon  = null;
            }
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (fncBlank())
            {
                return;
            }

            ArrayList arQuery = new ArrayList();

            GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection();
            string sqlQuery = "";
            Int32  NewId    = 0;
            Int64  ChkRel   = 0;

            try
            {
                //Member Master Table
                if (btnSave.Text.ToString() != "&Save")
                {
                    //Update data
                    sqlQuery = " Update tblEmp_Released Set dtReleased = '" + clsProc.GTRDate(dtReleasedDate.Value.ToString()) + "',remarks = '" + txtRemarks.Text.ToString() + "' Where RelID = " + Int32.Parse(txtId.Text.ToString());
                    arQuery.Add(sqlQuery);

                    // Insert Information To Log File
                    sqlQuery = "Insert Into tblUser_Trans_Log (LUserId, formName, tranStatement, PCName, tranType,EmpId)"
                               + " Values (" + Common.Classes.clsMain.intUserId + ", '" + this.Name.ToString() + "','" + sqlQuery.Replace("'", "|") + "','" + Common.Classes.clsMain.strComputerName + "','Update','" + cboEmpID.Value.ToString() + "')";
                    arQuery.Add(sqlQuery);


                    sqlQuery = " Update tblEmp_info Set dtReleased = '" + clsProc.GTRDate(dtReleasedDate.Value.ToString()) + "', IsInactive = 1 Where empid =  '" + cboEmpID.Value.ToString() + "' and ComId = " + Common.Classes.clsMain.intComId + "";
                    arQuery.Add(sqlQuery);

                    // Insert Information To Log File
                    sqlQuery = "Insert Into tblUser_Trans_Log (LUserId, formName, tranStatement, PCName, tranType,EmpId)"
                               + " Values (" + Common.Classes.clsMain.intUserId + ", '" + this.Name.ToString() + "','" + sqlQuery.Replace("'", "|") + "','" + Common.Classes.clsMain.strComputerName + "','Update','" + cboEmpID.Value.ToString() + "')";
                    arQuery.Add(sqlQuery);

                    //Transaction with database
                    clsCon.GTRSaveDataWithSQLCommand(arQuery);

                    MessageBox.Show("Data Updated Succefully.");
                }
                else
                {
                    sqlQuery = "Select dbo.fncCheckEmpRel (" + Common.Classes.clsMain.intComId + ", '" + cboEmpID.Value.ToString() + "')";
                    ChkRel   = clsCon.GTRCountingDataLarge(sqlQuery);


                    if (ChkRel == 1)
                    {
                        MessageBox.Show("This Employee ID already Exist. Please input another Employee ID.");
                        return;
                    }

                    //add new
                    sqlQuery = "Select Isnull(Max(RelID),0)+1 As NewId from tblEmp_Released";
                    NewId    = clsCon.GTRCountingData(sqlQuery);

                    //Insert data
                    sqlQuery = "Insert Into tblEmp_Released ( aId,RelID, empid, dtReleased, Remarks,ComId ,LUserId,PcName) "
                               + " Values (" + NewId + ", " + NewId + ", '" + cboEmpID.Value.ToString() + "', '" + clsProc.GTRDate(dtReleasedDate.Value.ToString()) + "',  '" + txtRemarks.Text.ToString() + "'," + Common.Classes.clsMain.intComId + "," + Common.Classes.clsMain.intUserId + ",'" + Common.Classes.clsMain.strComputerName + "')";
                    arQuery.Add(sqlQuery);

                    // Insert Information To Log File
                    sqlQuery = "Insert Into tblUser_Trans_Log (LUserId, formName, tranStatement, PCName, tranType,EmpId)"
                               + " Values (" + Common.Classes.clsMain.intUserId + ", '" + this.Name.ToString() + "','" + sqlQuery.Replace("'", "|") + "','" + Common.Classes.clsMain.strComputerName + "','Insert','" + cboEmpID.Value.ToString() + "')";
                    arQuery.Add(sqlQuery);



                    sqlQuery = " Update tblEmp_info Set dtReleased = '" + clsProc.GTRDate(dtReleasedDate.Value.ToString()) + "', IsInactive = 1  Where empid =  '" + cboEmpID.Value.ToString() + "' and ComId = " + Common.Classes.clsMain.intComId + "";
                    arQuery.Add(sqlQuery);

                    // Insert Information To Log File
                    sqlQuery = "Insert Into tblUser_Trans_Log (LUserId, formName, tranStatement, PCName, tranType,EmpId)"
                               + " Values (" + Common.Classes.clsMain.intUserId + ", '" + this.Name.ToString() + "','" + sqlQuery.Replace("'", "|") + "','" + Common.Classes.clsMain.strComputerName + "','Insert','" + cboEmpID.Value.ToString() + "')";
                    arQuery.Add(sqlQuery);

                    //Transaction with database
                    clsCon.GTRSaveDataWithSQLCommand(arQuery);

                    MessageBox.Show("Data Saved Successfully.");
                }
                prcClearData();
                cboEmpID.Focus();

                prcLoadList();
                prcLoadCombo();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                arQuery = null;
                clsCon  = null;
            }
        }
예제 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (fncBlank())
            {
                return;
            }

            ArrayList arQuery = new ArrayList();

            GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection();
            string sqlQuery = "";
            Int64  NewId    = 0;
            Int64  ChkCard  = 0;

            DateTime firstDay = new DateTime(dtCardAssign.DateTime.Year, dtCardAssign.DateTime.Month, 1);

            dtFrom.Value = firstDay;

            sqlQuery = "Select dbo.fncCheckCardAssign (" + Common.Classes.clsMain.intComId + ", '" + this.txtCard.Text.ToString() + "')";
            ChkCard  = clsCon.GTRCountingDataLarge(sqlQuery);

            if (ChkCard == 1)
            {
                MessageBox.Show("This Employee Card already Exist. Please input another Punch Card Number.");
                return;
            }

            try
            {
                //Update data
                sqlQuery = "Update tblEmp_Info Set CardNo = '" + txtCard.Text.ToString() + "' + 'Rel' Where ComId =  " + Common.Classes.clsMain.intComId + " and CardNo = '" + txtCard.Text.ToString() + "' and Len(CardNo)=10 and isinactive = 1";
                arQuery.Add(sqlQuery);

                sqlQuery = "Update tblEmp_Info Set dtCardAssign = '" + clsProc.GTRDate(dtCardAssign.Value.ToString()) + "',CardNo = '" + txtCard.Text.ToString() + "' Where ComId =  " + Common.Classes.clsMain.intComId + " and EmpId = " + Int32.Parse(txtId.Text.ToString());
                arQuery.Add(sqlQuery);

                // Insert Information To Log File
                sqlQuery = "Insert Into tblUser_Trans_Log (LUserId, formName, tranStatement, PCName, tranType,EmpId)"
                           + " Values (" + Common.Classes.clsMain.intUserId + ", '" + this.Name.ToString() + "','" + sqlQuery.Replace("'", "|") + "','" + Common.Classes.clsMain.strComputerName + "','Update','" + txtId.Value.ToString() + "')";
                arQuery.Add(sqlQuery);

                sqlQuery = "Update R Set R.EmpId = E.EmpId from tblRawData R,tblEmp_Info E Where R.CardNo = E.CardNo and E.CardNo = '" + txtCard.Text.ToString() + "' and R.dtPunchDate >= '" + clsProc.GTRDate(dtFrom.Value.ToString()) + "' and E.ComId =  " + Common.Classes.clsMain.intComId + "";
                arQuery.Add(sqlQuery);


                //Transaction with database
                clsCon.GTRSaveDataWithSQLCommand(arQuery);

                MessageBox.Show("Data Updated Succefully.");

                prcClearData();
                txtEmpCode.Focus();

                prcLoadList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                arQuery = null;
                clsCon  = null;
            }
        }