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  ChkData  = 0;

            DateTime lastDay = new DateTime(dtInputDate.DateTime.Year, dtInputDate.DateTime.Month, 1);

            lastDay           = lastDay.AddMonths(1);
            lastDay           = lastDay.AddDays(-(lastDay.Day));
            dtInputDate.Value = lastDay;

            try
            {
                //Member Master Table
                if (btnSave.Text.ToString() != "&Save")
                {
                    //Update data
                    sqlQuery = " Update tblSal_Addition Set dtInput = '" + clsProc.GTRDate(dtInputDate.Value.ToString()) + "', amount = '" + clsProc.GTRValidateDouble(txtAmt.Value.ToString()) + "',remarks = '" + txtRemarks.Text.ToString() + "' Where addID = " + Int32.Parse(txtId.Text.ToString());
                    arQuery.Add(sqlQuery);

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

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

                    MessageBox.Show("Data Updated Succefully.");
                }
                else
                {
                    sqlQuery = "Select dbo.fncCheckData (" + Common.Classes.clsMain.intComId + ",'" + cboEmpID.Value.ToString() + "','" + clsProc.GTRDate(dtInputDate.Value.ToString()) + "','Salary Addition')";
                    ChkData  = clsCon.GTRCountingDataLarge(sqlQuery);

                    if (ChkData == 1)
                    {
                        MessageBox.Show("This employee's salary addition amount already inputted. Please select another employee Id.");
                        return;
                    }

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

                    //Insert data
                    sqlQuery = "Insert Into tblSal_Addition ( aId,addID, empid, dtInput,amount, Remarks,LUserId,comid ,PcName) "
                               + " Values (" + NewId + ", " + NewId + ", '" + cboEmpID.Value.ToString() + "', '" + clsProc.GTRDate(dtInputDate.Value.ToString()) + "',  '" + clsProc.GTRValidateDouble(txtAmt.Value.ToString()) + "', '" + txtRemarks.Text.ToString() + "'," + Common.Classes.clsMain.intUserId + "," + Common.Classes.clsMain.intComId + ",'" + Common.Classes.clsMain.strComputerName + "')";
                    arQuery.Add(sqlQuery);

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

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

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

                prcLoadList();
                prcLoadCombo();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                arQuery = null;
                clsCon  = null;
            }
        }
Example #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;
            }
        }
        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;

            try
            {
                //Member Master Table
                if (btnSave.Text.ToString() != "&Save")
                {
                    //Update data
                    sqlQuery = " Update tblMobile_Deduct Set dtInput = '" + clsProc.GTRDate(dtInputDate.Value.ToString()) + "', amount = '" + clsProc.GTRValidateDouble(txtAmt.Value.ToString()) + "',remarks = '" + txtRemarks.Text.ToString() + "' Where dedctId = " + Int32.Parse(txtId.Text.ToString());
                    arQuery.Add(sqlQuery);

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

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

                    MessageBox.Show("Data Updated Succefully.");
                }
                else
                {
                    //add new
                    sqlQuery = "Select Isnull(Max(dedctId),0)+1 As NewId from tblMobile_Deduct";
                    NewId    = clsCon.GTRCountingData(sqlQuery);

                    //Insert data
                    sqlQuery = "Insert Into tblMobile_Deduct ( aId,dedctId, empid, dtInput,amount, Remarks,LUserId,comid ,PcName) "
                               + " Values (" + NewId + ", " + NewId + ", '" + cboEmpID.Value.ToString() + "', '" + clsProc.GTRDate(dtInputDate.Value.ToString()) + "',  '" + clsProc.GTRValidateDouble(txtAmt.Value.ToString()) + "', '" + txtRemarks.Text.ToString() + "'," + Common.Classes.clsMain.intUserId + "," + Common.Classes.clsMain.intComId + ",'" + Common.Classes.clsMain.strComputerName + "')";
                    arQuery.Add(sqlQuery);

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

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

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

                prcLoadList();
                prcLoadCombo();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                arQuery = null;
                clsCon  = null;
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (fncBlankA() == true)
            {
                return;
            }


            ArrayList arQuery = new ArrayList();

            GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection();
            dsList = new DataSet();
            int    NewID, slno;
            string AdmID;
            string sqlQuery;

            try
            {
                if (txtAdmsnID.Text.Length > 0)
                {
                    sqlQuery = "update  tblAdm_Form set frmNo='" + txtFormNo.Text.ToString() + "', nmFirst='" + txtNm.Text + "', nmMiddle='" + txtMn.Text
                               + "', nmLast='" + txtLn.Text.Trim() + "', nmFather='" + txtFatherNm.Text.Trim() + "', nmMother='" + txtMotherNm.Text.Trim()
                               + "', sesn='" + txtSesion.Text.Trim() + "',frmTakenDt='" + clsProc.GTRDate(dtAdmsn.Value.ToString()) + "',clsid='" + cboAdmisnFor.Value.ToString()
                               + "', sex = '" + cboSex.Text.Trim() + "', relegion = '" + cboReligion.Text.Trim() + "',mobile = '" + txtMobile.Text.Trim() + "',Phone = '" + txtPhone.Text.Trim()
                               + "', amount = " + txtAmt.Text.Trim() + ",Reference = '" + txtReferrance.Text.Trim() + "',remarks = '" + txtFrmRemarks.Text.Trim() + "' " +
                               " where admid='" + txtAdmsnID.Text + "'";
                    arQuery.Add(sqlQuery);

                    sqlQuery = "Insert Into GTRSystem.dbo.tblUser_Trans_Log (LUserId, formName, tranStatement, tranType)"
                               + " Values (" + Common.Classes.clsMain.intUserId + ", '" + this.Name.ToString() + "','" + sqlQuery.Replace("'", "|") + "','UPDATE')";
                    arQuery.Add(sqlQuery);
                    clsCon.GTRSaveDataWithSQLCommand(arQuery);
                    MessageBox.Show("Data Update Successfully");
                }
                else
                {
                    NewID = 0;
                    slno  = 0;

                    //Select ISNULL(max((right(frmNoAuto,6))),100000 )+1 as NewID from tblAdm_Form
                    sqlQuery = "Select ISNULL(max(frmNoAuto),100000 )+1 as NewID from tblAdm_Form";
                    AdmID    = clsCon.GTRCountingData(sqlQuery).ToString();

                    // string addata =AdmID.ToString().Substring(4, 6);
                    sqlQuery = "Select convert(int,ISNULL(max(AdmId),0 )+1) as NewID from tblAdm_Form";
                    NewID    = clsCon.GTRCountingData(sqlQuery);

                    //sqlQuery = "Select convert(int,ISNULL(max(slno),0 )+1) as slno from tblAdm_Form where sesn = '"+ txtSesion.Text +"' and clsId = '"+cboClas.Value.ToString()+ "'";
                    sqlQuery = "Select convert(int,ISNULL(max(slno),0 )+1) as slno from tblAdm_Form where sesn = '" + txtSesion.Text + "'";
                    slno     = clsCon.GTRCountingData(sqlQuery);


                    sqlQuery = "Insert Into tblAdm_Form (sesn,AdmId,slno, frmNo, frmNoAuto,nmFirst, nmMiddle, nmLast, nmFather, nmMother, clsid, yrNm,frmTakenDt,Address,sex,relegion,phone,mobile,amount,Reference,remarks)";
                    sqlQuery = sqlQuery + "values('" + txtSesion.Text.Trim() + "'," + NewID + "," + slno + ",'" + txtFormNo.Text.Trim() + "'," + AdmID + ",'" + txtNm.Text.Trim() + "','" + txtMn.Text.Trim() + "','" + txtLn.Text.Trim() + "','" + txtFatherNm.Text.Trim() + "','" + txtMotherNm.Text.Trim()
                               + "','" + cboAdmisnFor.Value.ToString() + "','" + txtSesion.Text.Trim() + "','" + clsProc.GTRDate(dtAdmsn.Value.ToString()) + "','" + txtAddress.Text + "','" + cboSex.Text + "','" + cboReligion.Text + "','" + txtPhone.Text + "','" + txtMobile.Text + "','" + txtAmt.Text + "','" + txtReferrance.Text + "','" + txtFrmRemarks.Text + "')";
                    arQuery.Add(sqlQuery);

                    sqlQuery = "Insert Into GTRSystem.dbo.tblUser_Trans_Log (LUserId, formName, tranStatement, tranType)"
                               + " Values (" + Common.Classes.clsMain.intUserId + ", '" + this.Name.ToString() + "','" + sqlQuery.Replace("'", "|") + "','Insert')";
                    arQuery.Add(sqlQuery);
                    clsCon.GTRSaveDataWithSQLCommand(arQuery);
                    MessageBox.Show("Data Saved Successfully");
                }
                PrcCleraData();
                PrcLoadList();
                PrcLoadCombo();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                clsCon  = null;
                arQuery = null;
            }
        }