Пример #1
0
        private void TextCode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Down)
            {
                using (var connection = new SqlConnection(ProjectFunctions.ConnectionString))
                {
                    CurrentControl = "TextCode";
                    var month = string.Empty;
                    if (TextMonth.Text.Length == 7)
                    {
                        month = TextMonth.Text.Substring(0, 2) + TextMonth.Text.ToString().Substring(TextMonth.Text.ToString().Length - 2, 2);
                    }
                    else
                    {
                        TextMonth.Focus();
                        return;
                    }
                    var Query = "SELECT empmst.EmpCode, empmst.EmpName, EmpFhName, DeptMst.DeptDesc,EmpMst.EmpPymtMode "
                                + " FROM            empmst INNER JOIN"
                                + " DeptMst ON empmst.EmpDeptCode = DeptMst.DeptCode "
                                + " Where EmpMst.EmpCode Not In (Select EmpCode From AtnData Where MonthYear='" + month + "')  And EmpMst.EmpDOL is null  Order By EmpName";
                    if (TextCode.Text.Trim().Length == 0)
                    {
                        ShowHelpWindow(Query);
                    }
                    else
                    {
                        var query = string.Format("SELECT  empmst.EmpCode, empmst.EmpName, DeptMst.DeptDesc,EmpMst.EmpPymtMode"
                                                  + " FROM            empmst Inner Join"
                                                  + " DeptMst ON empmst.EmpDeptCode = DeptMst.DeptCode where empmst.EmpCode='{0}' ", TextCode.Text.Trim());

                        var ds  = new DataSet();
                        var dap = new SqlDataAdapter(query, connection);
                        dap.Fill(ds);

                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            TextCode.Text       = ds.Tables[0].Rows[0]["EmpCode"].ToString();
                            TextCodeDesc.Text   = ds.Tables[0].Rows[0]["EmpName"].ToString();
                            TextDepartment.Text = ds.Tables[0].Rows[0]["DeptDesc"].ToString();
                            txtPaymentMode.Text = ds.Tables[0].Rows[0]["EmpPymtMode"].ToString();


                            TextWorked.Focus();
                        }
                        else
                        {
                            ShowHelpWindow(Query);
                        }
                    }
                    e.Handled = true;
                }
            }
            if ((e.KeyCode == Keys.Tab && e.Modifiers == Keys.Shift) || e.KeyCode == Keys.Up)
            {
                e.SuppressKeyPress = true;
                SelectNextControl(ActiveControl, false, true, true, true);
            }
        }
Пример #2
0
        private void RestoreFocus()
        {
            switch (CurrentControl)
            {
            case "TextCode":
                TextWorked.Focus();
                break;

            default:
                CurrentControl = string.Empty;
                break;
            }
        }
Пример #3
0
        private void HelpGridCtrl_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                var row = HelpGrid.GetDataRow(HelpGrid.FocusedRowHandle);
                switch (CurrentControl)
                {
                case "TextCode":
                    TextCode.Text       = row["EmpCode"].ToString();
                    TextCodeDesc.Text   = row["EmpName"].ToString();
                    TextDepartment.Text = row["DeptDesc"].ToString();
                    txtPaymentMode.Text = row["EmpPymtMode"].ToString();


                    TextWorked.Focus();
                    break;
                }

                HelpGridCtrl.Visible = false;
            }
            catch (Exception)
            {
            }
        }
Пример #4
0
 private void TextPrePaidTag_EditValueChanged(object sender, EventArgs e)
 {
     TextWorked.Focus();
 }
Пример #5
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
#pragma warning disable CS0618 // 'DXValidationProvider.InvalidControls' is obsolete: 'Use the GetInvalidControls method instead'
            if (MyValidationProvider.InvalidControls.Count > 0)
#pragma warning restore CS0618 // 'DXValidationProvider.InvalidControls' is obsolete: 'Use the GetInvalidControls method instead'
            {
                XtraMessageBox.Show("There is Some Error.", "Validation Failed");
                TextCode.Focus();
                return;
            }
            if (TextCode.Text == string.Empty)
            {
                XtraMessageBox.Show("Code can not be blank.", "Validation Failed");
                TextCode.Focus();
                return;
            }
            else
            {
                if (TextWorked.Text == string.Empty)
                {
                    XtraMessageBox.Show("Worked Days can not be Blank.", "Validation Failed");
                    TextWorked.Focus();
                    return;
                }

                else
                {
                    if (Convert.ToDecimal(TextPaidHolidays.EditValue) > 7)
                    {
                        XtraMessageBox.Show("Paid holidays cannot be greater than 7", "Validation Failed");
                        TextPaidHolidays.Focus();
                        return;
                    }
                    else
                    {
                        if ((Convert.ToDecimal(TextWorked.EditValue) + Convert.ToDecimal(TextPaidHolidays.EditValue) + Convert.ToDecimal(TextEarned.EditValue) + Convert.ToDecimal(TextCasual.EditValue) + Convert.ToDecimal(TextSick.EditValue)) > DaysInMonth)
                        {
                            XtraMessageBox.Show("Total Days can not be Exceed.", "Validation Failed");
                            TextWorked.Focus();
                            return;
                        }
                        else
                        {
                            using (var Connection = new SqlConnection(ProjectFunctions.ConnectionString))
                            {
                                var cmd = Connection.CreateCommand();
                                cmd.Connection = Connection;
                                var sql = string.Empty;
                                if (IsUpdate)
                                {
                                    sql = "UPDATE [AtnData] SET [MonthYear] = @MonthYear,[EmpCode] = @EmpCode,[EmpDW] = @EmpDW,[EmpPH] = @EmpPH,[EmpEL] = @EmpEL,[EmpCL] = @EmpCL,[EmpSL] = @EmpSL,[EmpOT] = @EmpOT,[EmpAdvAmt] = @EmpAdvAmt,[EmpLoanAmt] = @EmpLoanAmt,[EmpTdsAmt] = @EmpTdsAmt,[EmpMiscDed1] = @EmpMiscDed1,[EmpMiscAlw1] = @EmpMiscAlw1,[EmpMiscAlw2] = @EmpMiscAlw2,[EmpMiscAlw3] = @EmpMiscAlw3,[EmpPrePaidSal] = @EmpPrePaidSal,EmpML=@EmpML ,EmpMiscDed2=@EmpMiscDed2,EmpPymtMode=@EmpPymtMode"
                                          + " WHERE [EmpCode] = @EmpCode and [MonthYear] = @MonthYear";
                                }
                                else
                                {
                                    sql = " INSERT INTO [AtnData]([MonthYear],[EmpCode],[EmpDW],[EmpPH],[EmpEL],[EmpCL],[EmpSL],[EmpOT],[EmpAdvAmt],[EmpLoanAmt],[EmpTdsAmt],[EmpMiscDed1],[EmpMiscAlw1],[EmpMiscAlw2],[EmpMiscAlw3],[EmpLockTag],[EmpPrePaidSal],EmpML,EmpMiscDed2,EmpPymtMode)"
                                          + "VALUES" +
                                          "(@MonthYear,@EmpCode,@EmpDW,@EmpPH,@EmpEL,@EmpCL ,@EmpSL ,@EmpOT ,@EmpAdvAmt ,@EmpLoanAmt ,@EmpTdsAmt ,@EmpMiscDed1 ,@EmpMiscAlw1 ,@EmpMiscAlw2 ,@EmpMiscAlw3 ,@EmpLockTag,@EmpPrePaidSal,@EmpML,@EmpMiscDed2,@EmpPymtMode)";
                                }
                                Connection.Open();
                                cmd.CommandText = sql;
                                var month = TextMonth.Text.Substring(0, 2) + TextMonth.Text.ToString().Substring(TextMonth.Text.ToString().Length - 2, 2);
                                cmd.Parameters.AddWithValue("@MonthYear", TextMonth.Text).Value = month;
                                cmd.Parameters.AddWithValue("@EmpCode", TextCode.Text);
                                cmd.Parameters.AddWithValue("@EmpDW", SqlDbType.Decimal).Value = Convert.ToDecimal(TextWorked.Text);
                                if (TextPaidHolidays.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpPH", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpPH", SqlDbType.Decimal).Value = Convert.ToDecimal(TextPaidHolidays.Text);
                                }
                                if (TextEarned.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpEL", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpEL", SqlDbType.Decimal).Value = Convert.ToDecimal(TextEarned.Text);
                                }
                                if (TextCasual.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpCL", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpCL", SqlDbType.Decimal).Value = Convert.ToDecimal(TextCasual.Text);
                                }
                                if (TextSick.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpSL", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpSL", SqlDbType.Decimal).Value = Convert.ToDecimal(TextSick.Text);
                                }
                                if (TextOverTime.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpOT", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpOT", SqlDbType.Decimal).Value = Convert.ToDecimal(TextOverTime.Text);
                                }
                                if (TextAdvances.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpAdvAmt", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpAdvAmt", SqlDbType.Decimal).Value = Convert.ToDecimal(TextAdvances.Text);
                                }
                                if (TextLoanAmt.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpLoanAmt", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpLoanAmt", SqlDbType.Decimal).Value = Convert.ToDecimal(TextLoanAmt.Text);
                                }
                                if (TextTdsAmt.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpTdsAmt", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpTdsAmt", SqlDbType.Decimal).Value = Convert.ToDecimal(TextTdsAmt.Text);
                                }



                                if (TextDeducMisc.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpMiscDed1", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpMiscDed1", SqlDbType.Decimal).Value = Convert.ToDecimal(TextDeducMisc.Text);
                                }
                                if (TextMisc1.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpMiscAlw1", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpMiscAlw1", SqlDbType.Decimal).Value = Convert.ToDecimal(TextMisc1.Text);
                                }
                                if (TextMisc2.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpMiscAlw2", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpMiscAlw2", SqlDbType.Decimal).Value = Convert.ToDecimal(TextMisc2.Text);
                                }
                                if (TextMisc3.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpMiscAlw3", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpMiscAlw3", SqlDbType.Decimal).Value = Convert.ToDecimal(TextMisc3.Text);
                                }



                                if (txtMaternityLeave.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpML", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpML", SqlDbType.Decimal).Value = Convert.ToDecimal(txtMaternityLeave.Text);
                                }


                                cmd.Parameters.AddWithValue("@EmpLockTag", DBNull.Value);
                                if (IsUpdate)
                                {
                                    cmd.Parameters.AddWithValue("@EmpPrePaidSal", TextPrePaidTag.Text);
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpPrePaidSal", DBNull.Value);
                                }



                                if (txtMiscDedNew.Text == string.Empty)
                                {
                                    cmd.Parameters.AddWithValue("@EmpMiscDed2", SqlDbType.Decimal).Value = "0";
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@EmpMiscDed2", SqlDbType.Decimal).Value = Convert.ToDecimal(txtMiscDedNew.Text);
                                }

                                cmd.Parameters.AddWithValue("@EmpPymtMode", SqlDbType.Decimal).Value = txtPaymentMode.Text;
                                cmd.ExecuteNonQuery();

                                if (Convert.ToDecimal(TextWorked.Text) == 0)
                                {
                                    ProjectFunctions.GetDataSet("Delete from payfinal where monthyear='" + month + "' And EmpCode='" + TextCode.Text.Trim() + "'");
                                    ProjectFunctions.GetDataSet("Delete from Paytestf where monthyear='" + month + "' And EmpCode='" + TextCode.Text.Trim() + "'");
                                }
                                using (var Conn = new SqlConnection(ProjectFunctions.ConnectionString))
                                {
                                    var month2 = TextMonth.Text.Substring(0, 2) + TextMonth.Text.ToString().Substring(TextMonth.Text.ToString().Length - 2, 2);
                                    var str1   = string.Empty;

                                    TextMonth.Focus();
                                }
                            }
                            //BaseFunctions.GetDataSet(" Update exmst set ExLoadTag='1',ExLoadedDate='" + DateTime.Now.ToString("yyyy-MM-dd") + "' where ExEmpCode='" + TextCode.Text + "'  And  DATEPART(MM,ExMst.ExDatePost)='" + Convert.ToDateTime(TextMonth.Text).ToString("MM") + "' And  DATEPART(yyyy,ExMst.ExDatePost)='" + Convert.ToDateTime(TextMonth.Text).ToString("yyyy") + "' And ExLoadTag is null");



                            TextCode.Text            = string.Empty;
                            TextCodeDesc.Text        = string.Empty;
                            TextDepartment.EditValue = string.Empty;
                            TextWorked.Text          = "0";
                            TextPaidHolidays.Text    = "0";
                            TextOverTime.Text        = "0";
                            TextEarned.Text          = "0";
                            TextCasual.Text          = "0";
                            TextSick.EditValue       = "0";
                            TextMisc1.EditValue      = "0";
                            TextMisc2.Text           = "0";
                            TextMisc3.Text           = "0";
                            TextFlexiAlw.Text        = "0";
                            TextAdvances.Text        = "0";
                            TextLoanAmt.EditValue    = "0";
                            TextDeducMisc.Text       = "5";
                            TextTdsAmt.Text          = "0";
                            txtMaternityLeave.Text   = "0";
                            txtFood.Text             = "0";

                            TextPrePaidTag.Text = string.Empty;

                            txtTotalDays.Text = "0";

                            txtMiscDedNew.Text = "0";
                            TextMonth.Focus();
                            if (IsUpdate)
                            {
                                //XtraMessageBox.Show("Data Saved", "Success");
                                Close();
                                Dispose();
                            }
                        }
                    }
                }
            }
        }