Blog Of Sem: January 2019

C# ASPXGRIDVIEW GET TOTAL SUMMARY

protected void Buttonhepsiniode_Click(object sender, EventArgs e)
{
 
    //for (int i = 0; i < ASPxGridView2.VisibleRowCount; i++)
    //{
    //    var items = ASPxGridView2.GetRowValues(i, new string[] { "FISNO", "TL_BORC" }) as object[];
    //    // ASPxListBox1.Items.Add(rowValues[0].ToString());
    //    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();
    //    Labeltesekkurler.Visible = true;
    //}
    Decimal SMTUTAR = Convert.ToDecimal(ASPxGridView2.GetTotalSummaryValue(ASPxGridView2.TotalSummary["TL_BORC"]));
    Global.TUTAR = null;
    Global.TUTAR = SMTUTAR.ToString();
    Server.Transfer("payment.aspx");
}

C# DEVEXPRESS ASPXGRIDVIEW SELECTED ROWS TOTAL

protected void Button1_Click(object sender, EventArgs e)
{
    //List<object> SelectedDebts = grid.GetSelectedFieldValues(new string[] { "FISNO", "TL_BORC" });
    //foreach (object debts in SelectedDebts)
    //{
    //    IList items = debts 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();
    //    Labeltesekkurler.Visible = true;
    //}
 
 
    //List<object> SelectedDebts = grid.GetSelectedFieldValues(new string[] { "FISNO", "TL_BORC" });
    Decimal selectedTUTAR = 0;
    foreach (object value in ASPxGridView2.GetSelectedFieldValues("TL_BORC"))
    {
        {
            selectedTUTAR += Convert.ToDecimal(value);
        }
 
    }
 
    Global.TUTAR = null;
    Global.TUTAR = selectedTUTAR.ToString();
    Server.Transfer("payment.aspx");
 
}

LOGO SQL INFO KULLANIMI BARKOD YAZDA MIKTAR CIKSIN

_SQLINFO ("AMOUNT", "LG_219_01_STLINE", "LOGICALREF='"+STR(R9.logicalRef)+"'")


c# devexpress windows form skin

new c# windows form NOT DEVEXPRESS


add reference devexpress.bonusskins
devexpres.utils
devexpress.utils ui


DELETE FORM1 AND ADD DEVEXPRESS ITEM FORM

PROGRAM.CS :

            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("McSkin");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

visual c# encrypt decrypt text file

First create class : encrypt_decrypt.cs
inside:
using System;
using System.Security.Cryptography;
using System.Text;
 
namespace RestWebinarSample
{
 
    class Encryptor
    {
        public static string IV = "1a1a1a1a1a1a1a1a";
        public static string Key = "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a13";
 
        public static string Encrypt(string decrypted)
        {
            byte[] textbytes = ASCIIEncoding.ASCII.GetBytes(decrypted);
            AesCryptoServiceProvider endec = new AesCryptoServiceProvider();
            endec.BlockSize = 128;
            endec.KeySize = 256;
            endec.IV = ASCIIEncoding.ASCII.GetBytes(IV);
            endec.Key = ASCIIEncoding.ASCII.GetBytes(Key);
            endec.Padding = PaddingMode.PKCS7;
            endec.Mode = CipherMode.CBC;
            ICryptoTransform icrypt = endec.CreateEncryptor(endec.Key, endec.IV);
            byte[] enc = icrypt.TransformFinalBlock(textbytes, 0, textbytes.Length);
            icrypt.Dispose();
            return Convert.ToBase64String(enc);
        }
 
        public static string Decrypted(string encrypted)
        {
            byte[] textbytes = Convert.FromBase64String(encrypted);
            AesCryptoServiceProvider endec = new AesCryptoServiceProvider();
            endec.BlockSize = 128;
            endec.KeySize = 256;
            endec.IV = ASCIIEncoding.ASCII.GetBytes(IV);
            endec.Key = ASCIIEncoding.ASCII.GetBytes(Key);
            endec.Padding = PaddingMode.PKCS7;
            endec.Mode = CipherMode.CBC;
            ICryptoTransform icrypt = endec.CreateDecryptor(endec.Key, endec.IV);
            byte[] enc = icrypt.TransformFinalBlock(textbytes, 0, textbytes.Length);
            icrypt.Dispose();
            return System.Text.ASCIIEncoding.ASCII.GetString(enc);
        }
    }
}
 

then 2 buttons encrypt and decrypt

private void encrypt_Click(object sender, EventArgs e)
{
 
    Directory.CreateDirectory("data\\");
 
    var sw = new StreamWriter("data\\" + "data.ls");
 
    string enctxt = Encryptor.Encrypt("willbeencrypted");
 
    sw.WriteLine(enctxt);
 
    sw.Close();
}
 
private void decrypt_Click(object sender, EventArgs e)
{
    StreamReader sr = new StreamReader(Application.StartupPath + "\\data\\" + "data.ls");
    string line = sr.ReadLine();
 
    MessageBox.Show(Encryptor.Decrypted(Convert.ToString(line)));
}

EXCEPTION WRITE TO LOG

public void WRITELOG(string ERROR, Exception E, int TYPE)
 {
     try
     {
         string directory = AppDomain.CurrentDomain.BaseDirectory + "logs\\";
         Directory.CreateDirectory(directory);
         string EXTENTION = "";
         if (TYPE == 0)
             EXTENTION = " - ERRORS";
         else if (TYPE == 1)
             EXTENTION = " - STATUS";
         else if (TYPE == 2)
             EXTENTION = " - EXPS";
         string path = directory + DateTime.Now.ToString("yyyy.MM.dd" + EXTENTION) + ".txt";
         if (!File.Exists(path))
             File.Create(path).Close();
         else
         {
             if (TYPE > 0 || E == null)
                 File.AppendAllText(path, Environment.NewLine);
             else
                 File.AppendAllText(path, Environment.NewLine + Environment.NewLine +
                     Environment.NewLine + Environment.NewLine + Environment.NewLine);
         }
         File.AppendAllText(path, DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss"+ " : " + ERROR +
             Environment.NewLine + (E != null ? " ----- HATA : ----- " + E.ToString() : ""));
     }
     catch { }
 }

C# WEB SERVICE SORGULAMASI

using System;
using System.Windows.Forms;
 
namespace BMSLicenseKontrol
{
    public partial class Form1 : DevExpress.XtraEditors.XtraForm
    {
        public Form1()
        {
            InitializeComponent();
        }
 
 
        private void button1_Click(object sender, EventArgs e)
        {
 
 
 
        }
 
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            ServiceBMSLicense.LicenseServiceSoapClient SBMSLicense = new ServiceBMSLicense.LicenseServiceSoapClient();
            SBMSLicense.LicenseQuery(lisans.Text, GetStatikIp.GetIPAddress());
            MessageBox.Show(SBMSLicense.LicenseQuery(lisans.Text, GetStatikIp.GetIPAddress()).Rows[0][6].ToString()); //0rıncı row 6ıncı column MSGBOXDA GOSTER
            gridControl1.DataSource = SBMSLicense.LicenseQuery(lisans.Text, GetStatikIp.GetIPAddress());//ISDERSEN DIREK DONUSU GRIDVIEWDE GOSTER
 
 
        }
    }
}

c# CLASS GET STATIK IP

using System;
using System.IO;
using System.Net;
 
namespace BMSLicenseKontrol
{
    class GetStatikIp
    {
        public static string GetIPAddress()
 
        {
 
            String address = "";
 
            WebRequest request = WebRequest.Create("http://checkip.dyndns.org/");
 
            using (WebResponse response = request.GetResponse())
 
            using (StreamReader stream = new StreamReader(response.GetResponseStream()))
 
            {
 
                address = stream.ReadToEnd();
 
            }
 
            int first = address.IndexOf("Address: "+ 9;
 
            int last = address.LastIndexOf("</body>");
 
            address = address.Substring(first, last - first);
 
            return address;
 
        }
    }
}