Blog Of Sem: December 2018

Aspxgridview selected ve toplu işlemleri

--aşağıdaki kod bütün seçili rowlara işlem yapar
            List<object> SelectedUsers = grid.GetSelectedFieldValues(new string[] { "ID", "TUTAR" });
            foreach (object user in SelectedUsers)
            {
                IList items = user as IList;
                if (items == null) return;
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CarringtonWebConnectionString1"].ConnectionString);
                con.Open();
                SqlCommand cmd = new SqlCommand("update ACIKHESAP set ODEME_DURUMU=1, ODENEN_TUTAR=" + items[1].ToString() + " where ID=" + items[0].ToString(), con);
                cmd.ExecuteNonQuery();
            }


---aşağıdaki kod seçili seçili deil farketmez hepsine işlem yapar
            for (int i = 0; i < grid.VisibleRowCount; i++)
            {
                var items = grid.GetRowValues(i, new string[] { "ID", "TUTAR" }) as object[];
                // ASPxListBox1.Items.Add(rowValues[0].ToString());
                //you can add these key in a list here

                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CarringtonWebConnectionString1"].ConnectionString);
                con.Open();
                SqlCommand cmd = new SqlCommand("update ACIKHESAP set ODEME_DURUMU=2, ODENEN_TUTAR=" + items[1].ToString() + " where ID=" + items[0].ToString(), con);
                cmd.ExecuteNonQuery();

Sql toplu hareket görenleri kasmadan silme


declare @counter int
declare @numOfRecords int
declare @batchsize int

set @numOfRecords = 700924 --burdaki rakam databasei acip tables yazisini secip f7 basinca rowcountu en cok olan rakam

set @counter = 0
set @batchsize = 2500

set rowcount @batchsize
while @counter < (@numOfRecords/@batchsize) +1
begin
set @counter = @counter + 1
delete Erp_InventoryReceiptItem

update Erp_Invoice set InventoryReceiptId = null

update Erp_InventoryReceiptAttachment set  InventoryReceiptId = null

delete Erp_InventoryReceiptAttachment

delete Erp_InvoiceAttachment

delete Erp_WorkOrderProduction
UPDATE  Erp_InventoryReceiptItem set InventoryReceiptId=null
delete Erp_InventoryReceipt

update Erp_InventoryReceipt set InvoiceId=null
delete Erp_Invoice

delete Erp_BankAccountTotal

delete Erp_BankCredit
update Erp_CurrentAccountReceipt set BankReceiptId=null
delete Erp_BankReceiptItem

update Erp_ChequeReceipt set BankReceiptId=null

delete Erp_ChequeReceiptItem

delete Erp_ChequeReceiptAttachment

delete Erp_ChequeReceipt

delete Erp_BankReceiptAttachment

delete Erp_BankReceipt

delete Erp_CashTotalItem

delete Erp_CashTotal

delete Erp_Cheque

delete Erp_OrderReceiptItem

delete Erp_OrderReceiptAttachment

delete Erp_OrderReceipt

delete Erp_ContractItem

delete Erp_ContractAttachment

delete Erp_Contract

update Erp_InventoryReceipt set CurrentAccountReceiptId = null
delete Erp_CurrentAccountReceiptItem

delete Erp_CurrentAccountReceiptAttachment

delete Erp_CurrentAccountReceipt

delete Erp_CurrentAccountTotal

delete Erp_QuotationReceiptItem

delete Erp_QuotationReceiptAttachment

delete Erp_QuotationReceipt

delete Erp_DemandReceiptItem

delete Erp_DemandReceiptAttachment

delete Erp_DemandReceipt

delete Erp_WorkOrderItem

delete Erp_WorkOrderAttachment

delete Erp_WorkOrderExplanation

delete Erp_WorkOrder

delete Erp_GLReceiptItem
update Erp_InventoryReceipt set GLReceiptId=null

delete Erp_GLReceipt

Delete Erp_InventoryTotal

delete Erp_ReceiptPaymentItem

delete Meta_ForexRate

delete Erp_ServiceTotal

Delete Erp_GLAccountTotal

delete Erp_BankAccountTotal
update Erp_InventoryReceipt set PosReceiptId=null
delete erp_pos
delete Erp_InventoryReceipt
delete RPL_TaskTarget
delete Rpl_TaskItem
delete RPL_Task
delete Rpl_Xref
delete [LiveHareketler].[dbo].[Replication]
end
set rowcount 0


truncate table Log_Transaction


shrink işlemi:
USE LiveHareketler;
GO
ALTER DATABASE LiveHareketler
SET RECOVERY SIMPLE;
GO

--Datadakı log dosyasını shrınk yap yani database sağ tıkla task shrink files log->reorganize page 0 ve tamam ve sonrasındada yine databasee sağ tık task shrink database ok

ALTER DATABASE LiveHareketler
SET RECOVERY FULL;
GO

visual studio asp datasource olarak xmli kullanmak

new empty web project
insert new web page adı index.aspx
insert new item xml
içine :
<?xml version="1.0" encoding="utf-8" ?>
<Students>
  <Student
    StudentID="1"
    FirstName="A"
    LastName="AA"
    TotalMarks="100">
  </Student>
  <Student
    StudentID="2"
    FirstName="B"
    LastName="BB"
    TotalMarks="200">
  </Student>
  <Student
    StudentID="3"
    FirstName="C"
    LastName="CC"
    TotalMarks="500">
  </Student>
  <Student
    StudentID="4"
    FirstName="D"
    LastName="DD"
    TotalMarks="700">
  </Student>
</Students>

ve gridview at ve datasource xmlden xml dosyasını seç

alastyr plesk windows hostinge pcdeki sql serverden baglanma

once pleski acip sol tarafdan databesisden yeni kullanici yarat
ms sql secili olsun allow remote connections from secip altina who.isden ipni yaz

daha sonra database yeni database server sql server

sql serverede
server name sadece ornekserver.com yazilmasi yeterli
login pleskte database kısmında user managementta yaratilan kullanici ve parola

-------------------
visual studio asp proje deploy,
pleske visual studio aspxlerin projelerini ataiblmek icin alastyre pleskte web deployu aktif etmelerini soyle.
bu tarz link mail atacaklar sana https://mywebsite.xyz:8172/msdeploy.axd?site=mywebsite.xyz
bunu visual studioda solutiona sag tikla publishden web deployu secerek.

server: https://mywebsite.xyz:8172/msdeploy.axd?site=mywebsite.xyz
site: mywebsite.xyz/sw/test
user name:mywebsite (hostu alirken attiklari kullanici adi)
password:parola (hostu alirken attiklari kullanici adi)
destination url:mywebsite.xyz/sw/test

git ile projeyi sifirdan githuba yukleme

once projenin oldugu klasore sag tikla git bash here de

githubda new repositiries yarat ornek ad : asp_admin_panel_master_session
git init
git remote add origin https://github.com/semt20/asp_admin_panel_master_session.git
git add .
git commit -m "initial commit"
git push origin master


Visual studio gitlabdaki deişen kodları almak için :
team explorer
Sync
Fetch
Pull

devexpress aspx 17.2 localisation language

devexpress aspx turkcelestirme once projede web.confige gir ve   <globalization culture="tr-Tr" uiCulture="tr-Tr"/> ekle daha sonra devexpressin sitesinden
https://localization.devexpress.com/Localization/List turkceyi indir projenin bulundugu bin icine tr diye klasor ac ve icine at aynı zamanda C:\Program Files (x86)\DevExpress 17.2\Components\Bin\Framework\ burdada tr diye bir klasor ac ve icine at

ASPXGRIDVIEW İşlemleri

Gridviewde seçili satırın bilgisini alabilme :
        protected void ASPxGridView1_SelectionChanged(object sender, EventArgs e)
        {
            var products = ASPxGridView1.GetSelectedFieldValues("NAME");
            Label1.Text = products[0].ToString();
        }



Gridviewin Sonuna İşlemler Seç eklemek için source da sona ekle
            <dx:GridViewDataHyperLinkColumn Caption="İşlemler" FieldName="ID">
                <PropertiesHyperLinkEdit NavigateUrlFormatString="page.aspx?id={0}" Text="SEÇ" />
            </dx:GridViewDataHyperLinkColumn>


        </Columns>
    </dx:ASPxGridView>



Gridview devexpress 7.2 sonrası için gecerli export Gridview
<Columns>un altina ekle
 <SettingsExport EnableClientSideExportAPI="true" ExcelExportMode="WYSIWYG" />

<Columns>un ustune ekle
        <Toolbars>
            <dx:GridViewToolbar EnableAdaptivity="true">
                <Items>
                    <dx:GridViewToolbarItem Command="ExportToPdf" />
                    <dx:GridViewToolbarItem Command="ExportToXls" />
                    <dx:GridViewToolbarItem Command="ExportToXlsx" />
                    <dx:GridViewToolbarItem Command="ExportToDocx" />
                    <dx:GridViewToolbarItem Command="ExportToRtf" />
                    <dx:GridViewToolbarItem Command="ExportToCsv" />
                </Items>
            </dx:GridViewToolbar>
        </Toolbars>


Gridview grup category combobox ve baglantisi 
birinci sqldatasource_musteriler yarat ve bunu aspxgridviewe bind
Ikinci datasource sqldatasource_musterigruplari  yarat  bu bir yere bind olmayacak

Sqlden iki tablo yarat birinin adi musteri(id,adi,grupid) olsun
digeride musteri_grup (id,grup_adi) olsun

aspxgridview designerda columnsa tikla combobox column ekle captionunu grup yap, Fieldname grupid sec, sag tabda comboboxpropertiesde datasourceid musteri_gruplarini sec text field grup_adi , valuefield=id 


Gridview Horizontal scrollbar 

    <dx:ASPxGridView Width="100%" ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" KeyFieldName="ID" OnCellEditorInitialize="ASPxGridView1_CellEditorInitialize">

        <Settings ShowFilterRow="True" ShowGroupPanel="True" />

        <Settings HorizontalScrollBarMode="Auto" />

        <Settings VerticalScrollBarMode="Auto" />

Datasource eklemede hata alırsan sol taraftan server explorerden modify deyip save passwordu seç






Gridview  Required zorunlu alan ayari
Designerda ac ve columnsdan zorunlu alana tıkla ve sağda textboxpropertiesden en aşağıda validation settingste requiredi true yap





Master Detail Grid
ONCE 2 TANE SQLDATASOURCE VE 2 TANE ASPXGRIDVIEW YARAT BIRI MUSTERILER DIGERI MUSTERI HAREKETLER
MUSTERILERI NORMAL TABLODAN AL ASPXGRIDVIEW MUSTERILERIN SETTINGS DETAILDE DETAILROWU TRUE YAP,

MUSTERI HAREKETLERINIDE AL WHERE KISMINA TIKLA COLUMN MUSTERI_ID OPERATOR " = "  , SOURCE SESSION , SESSION FIELD = MUSTERI_ID

VE DAHA SONRA KODA EKLE
        protected void ASPxGridViewmusterihareketler_BeforePerformDataSelect(object sender, EventArgs e)
        {
            Session["MUSTERI_ID"] = (sender as ASPxGridView).GetMasterRowKeyValue();
        }


SON OLARAKDA ASPXGRIDVIEWMUSTERILERE TIKLA EDITTEMPLATE VE DETAILROWU SEC VE ASPXGRIDMUSTERIHAREKETLERINI ICINE SURUKLE VE END TEMPLATE YAP




Gridviewda son kolumun genişliğini max yapmak
        <Columns>
            <dx:GridViewCommandColumn ShowDeleteButton="True" ShowEditButton="True" ShowNewButtonInHeader="True" VisibleIndex="0">
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn FieldName="ID" ReadOnly="True" VisibleIndex="1">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="ADI" VisibleIndex="2" Width="100%">
            </dx:GridViewDataTextColumn>
        </Columns>



gridview detay masterda detay width sorunu once masterin altina ekle :
    <dx:ASPxGridView Width="100%" 
        <Settings HorizontalScrollBarMode="Auto" />
        <Settings VerticalScrollBarMode="Auto" />

sonra masterin son colomunun widthini %100 yap
  <dx:GridViewDataTextColumn FieldName="ADI" VisibleIndex="2" Width="100%">

sonra detaya ekle
   <dx:ASPxGridView2 Width="100%" 
        <Settings HorizontalScrollBarMode="Auto" />
        <Settings VerticalScrollBarMode="Auto" />

Github visual studio asp .net core projesi alip uyumlamak

git clone https://github.com/etrupja/DrinkAndGo.git

sonra projeyi aç appsettings.jsondan veritabanını deiş
Data Source=DESKTOP-PA213SA;Initial Catalog=dtest;Persist Security Info=True;User ID=sa;Password=2323211

view other window package manager consolea gir
ve aşağıya yazz önce
add-migration "Initial"
update-database

Live Hareket Goren istenmeyen malzemeleri toplu olarak sqlden silme

Silinmesi isdenilen malzemelerin recidleri () lerin icine yazilir

--update Erp_InventoryPriceList set UnitSetItemId = null where InventoryId in
--()

--delete Erp_InventoryPriceList where InventoryId in
--()

--delete Erp_RecipeItem from Erp_RecipeItem RI 
--where RecipeId = (Select RecId from Erp_Recipe R where R.RecId = RI.RecipeId and R.InventoryId in
--()
--)


--delete Erp_Recipe  where InventoryId in
--()

--update Erp_Inventory Set RecipeUnitItemId = null where RecId in
--()

--update Erp_InventoryUnitItemSize set InventoryId = null where InventoryId in
--()

--delete Erp_InventoryUnitItemSize where InventoryId in
--()

--delete Erp_InventoryBarcode where InventoryId in
--()

--delete Erp_InventoryWarehouse where InventoryId in
--()

--delete Erp_Project where InventoryId in
--()

--delete Erp_FixedAssetDepreciation where InventoryId in
--()

--delete Erp_InventoryExplanation where InventoryId in
--()

--delete Erp_InventoryAlternative  where InventoryId in
--()

--delete Erp_FixedAssetExpense  where InventoryId in
--()

--delete Erp_InventoryAttachment where InventoryId in
--()

--delete Erp_InitialCostItem from Erp_InitialCostItem IC 
--where InitialCostId = (Select RecId from Erp_InitialCost I where I.RecId = IC.InitialCostId and I.InventoryId in
--()
--)

--delete Erp_InitialCost where InventoryId in
--()

--delete Erp_RecipeItem where InventoryId in
--()

--delete Erp_RouteItem from Erp_RouteItem RI where RouteId = (select RecId from Erp_Route R where RI.RouteId=R.RecId and R.InventoryId in
--()
--)

--delete Erp_Route where InventoryId in
--()

--delete Erp_Inventory where RecId in
--()

Bootstrap Pass ID to Modal

 <script src="vendor/datatables/buttons/jquery-3.2.1.slim.min.js"></script>
 <script src="vendor/datatables/buttons/popper.min.js"></script>
  <link href="vendor/datatables/buttons/buttons.bootstrap4.min.css" rel="stylesheet">
  <link href="vendor/datatables/buttons/responsive.bootstrap4.min.css" rel="stylesheet">
  <link href="vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">


<a href="#" data-target="#my_modal" data-toggle="modal" class="identifyingClass" data-id="my_id_value">Open Modal</a>

<div class="modal fade" id="my_modal" tabindex="-1" role="dialog" aria-labelledby="my_modalLabel">
<div class="modal-dialog" role="dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">Modal Title</h4>
        </div>
        <div class="modal-body">
            Modal Body
            <input type="text" name="hiddenValue" id="hiddenValue" value="" />
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
            <button type="button" class="btn btn-primary">Yes</button>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $(".identifyingClass").click(function () {
            var my_id_value = $(this).data('id');
            $(".modal-body #hiddenValue").val(my_id_value);
        })
    });
</script>

Visual c# asp icin windows 10 asp yükleme


Sentez Live Dev - Sql Queryden Hareketlerin Silinmesi

Aşağıdaki sorgu liveda (peşin satışsız,ncrsız) kartlar dışında hareketleri siler:(malzeme fişleri ,irsaliyeler,faturalar,teklifler,sipariş,muhasebe fişi,banka çek fişleri).
Sildikten sonra shrink yapılmalı aşağıda nasıl yapıldığı anlatılmıştır.Yaklaşık 14 gblık datayı 700mba düşürdü.

delete Erp_InventoryReceiptItem
update Erp_Invoice set InventoryReceiptId = null
update Erp_InventoryReceiptAttachment set  InventoryReceiptId = null
delete Erp_InventoryReceiptAttachment
delete Erp_InvoiceAttachment
delete Erp_WorkOrderProduction
delete Erp_InventoryReceipt
delete Erp_Invoice
delete Erp_BankAccountTotal
delete Erp_BankCredit
delete Erp_BankReceiptItem
update Erp_ChequeReceipt set BankReceiptId=null
delete Erp_ChequeReceiptItem
delete Erp_ChequeReceiptAttachment
delete Erp_ChequeReceipt
delete Erp_BankReceiptAttachment
delete Erp_BankReceipt
delete Erp_CashTotalItem
delete Erp_CashTotal
delete Erp_Cheque
delete Erp_OrderReceiptItem
delete Erp_OrderReceiptAttachment
delete Erp_OrderReceipt
delete Erp_ContractItem
delete Erp_ContractAttachment
delete Erp_Contract
delete Erp_CurrentAccountReceiptItem
delete Erp_CurrentAccountReceiptAttachment
delete Erp_CurrentAccountReceipt
delete Erp_CurrentAccountTotal
delete Erp_QuotationReceiptItem
delete Erp_QuotationReceiptAttachment
delete Erp_QuotationReceipt
delete Erp_DemandReceiptItem
delete Erp_DemandReceiptAttachment
delete Erp_DemandReceipt
delete Erp_WorkOrderItem
delete Erp_WorkOrderAttachment
delete Erp_WorkOrderExplanation
delete Erp_WorkOrder
delete Erp_GLReceiptItem
delete Erp_GLReceipt
Delete Erp_InventoryTotal
delete Erp_ReceiptPaymentItem
delete Meta_ForexRate
delete Erp_ServiceTotal
Delete Erp_GLAccountTotal
delete Erp_BankAccountTotal
truncate table Log_Transaction

shrink işlemi:
USE LiveHareketler;
GO
ALTER DATABASE LiveHareketler
SET RECOVERY SIMPLE;
GO

--Datadakı log dosyasını shrınk yap yani database sağ tıkla task shrink files log->reorganize page 0 ve tamam ve sonrasındada yine databasee sağ tık task shrink database ok

ALTER DATABASE LiveHareketler
SET RECOVERY FULL;
GO


Laravel Php QuickAdmin Github

https://github.com/LaravelDaily/quickadmin

c:\wamp64\www icine LaravelDaily klasor yarat not php 7 ve ustu olmalı systen enviromant path..
eğer pcde hem iis hem wamp kullanıyorsun portlar cakisacak wampin portunu deis


C:\wamp64\bin\apache\apache2.4.35\conf\httpd.conf
Listen 0.0.0.0:80>>Listen 0.0.0.0:8081
Listen [::0]:80>>Listen [::0]:8081

c:\wamp64\www icine LaravelDaily klasor yarat
ve cmdde oraya git
composer global require laravel/installer
composer create-project laravel/laravel QuickAdmin --prefer-dist

cd QuickAdmin
composer clear-cache
composer require laraveldaily/quickadmin

open;
C:\wamp64\www\LaravelDaily\QuickAdmin\config\app.php

in the $providers array;
Laraveldaily\Quickadmin\QuickadminServiceProvider::class,


C:\wamp64\www\LaravelDaily\QuickAdmin\.env
*database connection is required. Check your .env file
DB_CONNECTION=mysql

DB_HOST=localhost

DB_PORT=3306

DB_DATABASE=quickadmin

DB_USERNAME=root

DB_PASSWORD=


---------------------
C:\wamp64\www\LaravelDaily\QuickAdmin\app\Providers\AppServiceProvider.php dosyasını duzenle
use Illuminate\Support\Facades\Schema;
public function boot()
    {
 Schema::defaultStringLength(191);
}
------------------
php artisan quickadmin:install
kullanıcı adı eposta sifre belirle
--------------------
C:\wamp64\www\LaravelDaily\QuickAdmin\app\Http\Kernel.php
bu kismin icine asagidakini ekle protected $routeMiddleware = [
'role' => \Laraveldaily\Quickadmin\Middleware\HasPermissions::class,

--------------
datatablellarda export etmesini isdersen : bu dosyayı bul ekle
C:\wamp64\www\LaravelDaily\QuickAdmin\resources\views\admin\partials\javascripts.blade.php


<script src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js"></script> 
<script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.flash.min.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script> 
<script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js"></script> 
<script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.print.min.js"></script> 


ve bu boyle olsun
    $('#datatable').dataTable( {
        "language": {
            "url": "{{ trans('quickadmin::strings.datatable_url_language') }}"
        },
        dom: 'Bfrtip'
    });
---------------
dili türkçeleştirmek için bu dosyadan:C:\wamp64\www\LaravelDaily\QuickAdmin\resources\lang\vendor\laraveldaily\en\admin.php
-----------------
eger menuden fazlaliklari kaldirmak isdersen dosyayı düzenle : C:\wamp64\www\LaravelDaily\QuickAdmin\resources\views\admin\partials\sidebar.blade.php


son olarak
php artisan serve ve http://127.0.0.1:8000/admin git