/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/ga/month_report.aspx.vb
142 строки
6 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
Imports sharedClasses.dbFunctions Partial Class GA_month_report Inherits System.Web.UI.Page Private sqlf As New SqlFunctions Protected Sub report_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles report.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then 'Dim rowView As Data.DataRowView = CType(e.Row.DataItem, Data.DataRowView) For Each c As TableCell In e.Row.Cells c.Text = c.Text.Replace(",", " ") Next Try e.Row.Cells(1).Controls.Add(New Image With {.ImageUrl = CType(e.Row.DataItem, Data.DataRowView)("photo"), .CssClass = "thumbnail"}) Catch ex as Exception End Try If CType(e.Row.DataItem, Data.DataRowView)("MONTH_IS_FIXED") = 1 Then e.Row.Style.Add("background", "LightGreen") End If End If End Sub Protected Sub Page_PreRenderComplete(sender As Object, e As EventArgs) Handles Me.PreRenderComplete Using sqlf Dim periodStart, periodEnd As String periodStart = Date.Parse(month.SelectedValue & "-01").ToString("yyyy-MM-dd") 'Date.Parse(month.SelectedValue & "-25").AddMonths(-1).AddDays(1).ToString("yyyy-MM-dd") periodEnd = Date.Parse(month.SelectedValue & "-01").AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd") ' month.SelectedValue & "-25" If sqlf.GetScalar("SELECT count(fixed) FROM hr.dbo.[TB_DRIVER_MONTHLY_PAYMENTS] WHERE [MONTH]='" & month.SelectedValue & "'") = 0 Then 'Month not fixed yet, get data from view 'sqlf.NonQuery("UPDATE UserModules.[user].[DRIVER_DAILY] " & ' "SET PERIOD = '" & month.SelectedValue & "'" & ' "WHERE [DATE] BETWEEN '" & periodStart & "' AND '" & periodEnd & "'") sdsReport.SelectCommand = sdsReport.SelectCommand.Replace("TB_DRIVER_MONTHLY_PAYMENTS", "VI_DRIVER_MONTHLY_PAYMENTS") Else ' month is fixed , taking data from table End If lblPeriod.Text = periodStart & " / " & periodEnd report.DataSource = sdsReport report.DataBind() ' Label1.Text = sdsReport.SelectCommand End Using End Sub Protected Sub Page_SaveStateComplete(sender As Object, e As EventArgs) Handles Me.SaveStateComplete Try Dim ttlROw As GridViewRow = report.Rows(report.Rows.Count - 1) For Each c As TableCell In ttlROw.Cells c.Style.Add("background-color", "SteelBlue") c.Style.Add("color", "White") c.Style.Add("font-weight", "bold") Next ttlROw.Cells(0).ColumnSpan = 3 ttlROw.Cells(0).Text = "Total" ttlROw.Cells(0).HorizontalAlign = HorizontalAlign.Center ttlROw.Cells.RemoveAt(2) ttlROw.Cells.RemoveAt(1) Catch ex As Exception End Try End Sub Protected Sub refresh_Click(sender As Object, e As ImageClickEventArgs) Handles refresh.Click month.DataBind() End Sub Protected Sub confirm_Click(sender As Object, e As ImageClickEventArgs) Handles confirm.Click Using sqlf Dim sql As New StringBuilder sql.AppendLine("WITH SRC as ( ") sql.AppendLine("SELECT * FROM hr.dbo.VI_DRIVER_MONTHLY_PAYMENTS ") sql.AppendLine("WHERE MONTH = '" & month.SelectedValue & "' ") sql.AppendLine(") ") sql.AppendLine("MERGE hr.dbo.TB_DRIVER_MONTHLY_PAYMENTS as trg ") sql.AppendLine("using src ") sql.AppendLine("on trg.[month] = src.[month] and trg.[driver] = src.[driver] ") sql.AppendLine("when not matched then ") sql.AppendLine("insert ") sql.AppendLine(" ([MONTH] ") sql.AppendLine(" ,[DRIVER] ") sql.AppendLine(" ,[THIS_MONTH_WORK_DAYS] ") sql.AppendLine(" ,[WORKED_DAYS] ") sql.AppendLine(" ,[MONTH_RATE] ") sql.AppendLine(" ,[SALARY] ") sql.AppendLine(" ,[OVERTIME] ") sql.AppendLine(" ,[GROSS_SALARY] ") sql.AppendLine(" ,[EXPENSE] ") sql.AppendLine(" ,[PREPAYMENT] ") sql.AppendLine(" ,[TC_PROFIT] ") sql.AppendLine(" ,[SECOND_PAYMENT] ") sql.AppendLine(" ,[TAX_13] ") sql.AppendLine(" ,[TAX_305] ") sql.AppendLine(" ,[TOTAL] ") sql.AppendLine(" ,MONTH_IS_FIXED ") sql.AppendLine(" ,FIXED ") sql.AppendLine(" ) ") sql.AppendLine("VALUES ( ") sql.AppendLine("[MONTH] ") sql.AppendLine(" ,[DRIVER] ") sql.AppendLine(" ,[THIS_MONTH_WORK_DAYS] ") sql.AppendLine(" ,[WORKED_DAYS] ") sql.AppendLine(" ,[MONTH_RATE] ") sql.AppendLine(" ,[SALARY] ") sql.AppendLine(" ,[OVERTIME] ") sql.AppendLine(" ,[GROSS_SALARY] ") sql.AppendLine(" ,[EXPENSE] ") sql.AppendLine(" ,[PREPAYMENT] ") sql.AppendLine(" ,[TC_PROFIT] ") sql.AppendLine(" ,[SECOND_PAYMENT] ") sql.AppendLine(" ,[TAX_13] ") sql.AppendLine(" ,[TAX_305] ") sql.AppendLine(" ,[TOTAL] ") sql.AppendLine(" , 1 ") sql.AppendLine(" , getdate()); ") sqlf.NonQuery(sql.ToString) End Using End Sub Protected Sub ImageButton1_Click(sender As Object, e As ImageClickEventArgs) Handles ImageButton1.Click Using sqlf sqlf.NonQuery("DELETE FROM hr.dbo.TB_DRIVER_MONTHLY_PAYMENTS WHERE [MONTH] = '" & month.SelectedValue & "'") End Using End Sub Protected Sub month_SelectedIndexChanged(sender As Object, e As EventArgs) Handles month.SelectedIndexChanged Dim m As String = month.SelectedValue If m > "2024-12" Then Response.Redirect("month_report_new.aspx?month=" + m) End If End Sub Protected Sub month_DataBound(sender As Object, e As EventArgs) Handles month.DataBound Try Dim m As String = Request.QueryString("month") If m <> "" Then month.SelectedValue = m End If Catch ex As Exception End Try End Sub End Class