Exemplo n.º 1
0
        public string CreateGlCard(string FIRMA_KODU, string ophCode, string description)
        {
            UnityObjects.IData itemCodeObj = default(UnityObjects.IData);
            UnityObjects.Query UnityQuery  = default(UnityObjects.Query);

            if (_GLOBAL_PARAMETERS.Global.UnityApp.Connected)
            {
                string[] OCODE = ophCode.Split('.');
                if (OCODE[3].Length != 4)
                {
                    OCODE[3] = OCODE[3].ToString().Substring(0, 4).ToString();
                }
                ophCode = OCODE[0] + "." + OCODE[1] + "." + OCODE[2] + "." + OCODE[3];

                UnityQuery = _GLOBAL_PARAMETERS.Global.UnityApp.NewQuery();
                string CARI_KONTROL = string.Empty;
                UnityQuery.Statement = "Select CODE From LG_" + FIRMA_KODU + "_EMUHACC where CODE='" + ophCode + "'";
                if (UnityQuery.OpenDirect())
                {
                    if (UnityQuery.First())
                    {
                        return(ophCode);
                    }
                    else
                    {
                        itemCodeObj = _GLOBAL_PARAMETERS.Global.UnityApp.NewDataObject(UnityObjects.DataObjectType.doGLAccount);
                        itemCodeObj.New();
                        itemCodeObj.DataFields.FieldByName("CODE").Value           = ophCode;
                        itemCodeObj.DataFields.FieldByName("DESCRIPTION").Value    = description;
                        itemCodeObj.DataFields.FieldByName("ACCOUNT_TYPE").Value   = 2;
                        itemCodeObj.DataFields.FieldByName("DATA_REFERENCE").Value = "~";
                        ValidateErrors err = itemCodeObj.ValidateErrors;
                        if (itemCodeObj.Post())
                        {
                            return(ophCode);
                        }
                        else
                        {
                            for (int i = 0; i < err.Count; i++)
                            {
                                ophCode = err[i].Error + "," + err[i].ID;
                            }
                        }
                    }
                }
            }
            return(ophCode);
        }
Exemplo n.º 2
0
        private void PAZARLAMA_STI_EKLE(int ID, string CODE, string _SIRKET_NO, string TYPE, string YERLI_YABANCI)
        {
            string unitSet    = "ADET"; // FATURADAN OKU
            string itemCodes  = string.Empty;
            string EVRAK_MAIL = string.Empty;

            using (SqlConnection myConnections = new SqlConnection(_GLOBAL_PARAMETERS._CONNECTIONSTRING_MDB.ToString()))
            {
                myConnections.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection     = myConnections;
                cmd.CommandTimeout = 0;
                cmd.CommandText    = "SELECT  *  from dbo.ADM_PAZARLAMA_SIRKETI where  ID=@ID";
                cmd.Parameters.AddWithValue("@ID", ID);
                SqlDataReader sqlreaders = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (sqlreaders.Read())
                {
                    string             BR_CARI_BILGI = string.Empty;
                    UnityObjects.IData Cari          = default(UnityObjects.IData);
                    if (_GLOBAL_PARAMETERS.Global.UnityApp.Connected)
                    {
                        Query  CARI_SORGULA = _GLOBAL_PARAMETERS.Global.UnityApp.NewQuery();
                        string CARI_KONTROL = string.Empty;
                        CARI_SORGULA.Statement = " SELECT  CODE  FROM  dbo.LG_" + _SIRKET_NO + "_CLCARD  WHERE (dbo.LG_" + _SIRKET_NO + "_CLCARD.CODE='" + CODE + "')";
                        if (CARI_SORGULA.OpenDirect())
                        {
                            Cari = _GLOBAL_PARAMETERS.Global.UnityApp.NewDataObject(UnityObjects.DataObjectType.doAccountsRP);
                            Cari.New();
                            Cari.DataFields.FieldByName("ACCOUNT_TYPE").Value    = 3;
                            Cari.DataFields.FieldByName("CODE").Value            = CODE;
                            Cari.DataFields.FieldByName("TITLE").Value           = sqlreaders["UNVANI"];
                            Cari.DataFields.FieldByName("ADDRESS1").Value        = sqlreaders["ADRESI"];
                            Cari.DataFields.FieldByName("ADDRESS2").Value        = sqlreaders["ADRESI_IKI"];
                            Cari.DataFields.FieldByName("TOWN_CODE").Value       = sqlreaders["ILCE_CODE"]; // "İlçe";
                            Cari.DataFields.FieldByName("TOWN").Value            = sqlreaders["ILCE"];      // "İlçe";
                            Cari.DataFields.FieldByName("CITY_CODE").Value       = sqlreaders["IL_CODE"];;
                            Cari.DataFields.FieldByName("CITY").Value            = sqlreaders["IL"];
                            Cari.DataFields.FieldByName("COUNTRY_CODE").Value    = sqlreaders["ULKE_CODE"];
                            Cari.DataFields.FieldByName("COUNTRY").Value         = sqlreaders["ULKE"];
                            Cari.DataFields.FieldByName("POSTAL_CODE").Value     = sqlreaders["POSTA_KODU"];//"Posta Kodu";
                            Cari.DataFields.FieldByName("TELEPHONE1_CODE").Value = sqlreaders["TELEFON_CODE"];
                            Cari.DataFields.FieldByName("TELEPHONE1").Value      = sqlreaders["TELEFON"];
                            Cari.DataFields.FieldByName("FAX_CODE").Value        = sqlreaders["FAX_CODE"];
                            Cari.DataFields.FieldByName("FAX").Value             = sqlreaders["FAX"];
                            // Cari.DataFields.FieldByName("TAX_ID").Value = sqlreaders["VERGI_NO"];  // "Vergi No";
                            Cari.DataFields.FieldByName("TAX_OFFICE").Value    = sqlreaders["VERGI_DAIRESI"];                                     //"Vergi Dairesi";
                            Cari.DataFields.FieldByName("CONTACT").Value       = sqlreaders["CONTACT"];                                           // "İsim Soyisim";
                            Cari.DataFields.FieldByName("E_MAIL").Value        = sqlreaders["EMAIL"];                                             //"E- Posta";
                            Cari.DataFields.FieldByName("GL_CODE").Value       = CreateGlCard(_SIRKET_NO, CODE, sqlreaders["UNVANI"].ToString()); // CreateGlCard(FIRMA_KODU, CODE, TITLE);// "Muhasebe Numarası";
                            Cari.DataFields.FieldByName("BANK_NAME1").Value    = sqlreaders["BANKA_ADI1"];
                            Cari.DataFields.FieldByName("BANK_ACCOUNT1").Value = sqlreaders["HESAP_NO"];

                            Cari.DataFields.FieldByName("EXT_SEND_EMAIL").Value    = sqlreaders["EMAIL"];
                            Cari.DataFields.FieldByName("ITR_SEND_MAIL_ADR").Value = sqlreaders["EMAIL"];
                            EVRAK_MAIL = sqlreaders["EMAIL"].ToString();
                            if (TYPE == "SAHIS")
                            {
                                Cari.DataFields.FieldByName("PERSCOMPANY").Value = 1;
                                Cari.DataFields.FieldByName("TCKNO").Value       = sqlreaders["TC_KIMLIK_NO"];
                            }
                            else
                            {
                                // Cari.DataFields.FieldByName("PERSCOMPANY").Value = 0;
                                Cari.DataFields.FieldByName("TAX_ID").Value = sqlreaders["VERGI_NO"];
                            }


                            if (YERLI_YABANCI == "YERLI")
                            {
                                Cari.DataFields.FieldByName("ISFOREIGN").Value = 0;

                                if (sqlreaders["IBAN"].ToString().Length >= 26)
                                {
                                    Cari.DataFields.FieldByName("BANK_IBAN1").Value = sqlreaders["IBAN"];
                                }
                            }
                            else
                            {
                                string BANK_NAME1 = "";
                                if (sqlreaders["BANKA_ADI1"].ToString().Length < 20)
                                {
                                    BANK_NAME1 = sqlreaders["BANKA_ADI1"].ToString();
                                }
                                else
                                {
                                    BANK_NAME1 = sqlreaders["BANKA_ADI1"].ToString().Substring(0, 19);
                                }
                                if (sqlreaders["SWIFT_CODE"].ToString().Length < 28)
                                {
                                    BANK_NAME1 += sqlreaders["SWIFT_CODE"].ToString();
                                }
                                else
                                {
                                    BANK_NAME1 += sqlreaders["SWIFT_CODE"].ToString().Substring(0, 19);
                                }


                                string BANK_ACCOUNT1 = "";
                                if (sqlreaders["HESAP_NO"].ToString().Length < 20)
                                {
                                    BANK_ACCOUNT1 = sqlreaders["HESAP_NO"].ToString();
                                }
                                else
                                {
                                    BANK_ACCOUNT1 = sqlreaders["HESAP_NO"].ToString().Substring(0, 19);
                                }
                                if (sqlreaders["ABA"].ToString().Length < 28)
                                {
                                    BANK_ACCOUNT1 += sqlreaders["ABA"].ToString();
                                }
                                else
                                {
                                    BANK_ACCOUNT1 += sqlreaders["ABA"].ToString().Substring(0, 19);
                                }



                                Cari.DataFields.FieldByName("BANK_NAME1").Value    = BANK_NAME1;
                                Cari.DataFields.FieldByName("BANK_ACCOUNT1").Value = BANK_ACCOUNT1;

                                Cari.DataFields.FieldByName("ISFOREIGN").Value = 1;
                            }


                            //Cari.DataFields.FieldByName("SUBSCRIBER_EXT").Value = "Ekstra bilgi";
                            //Cari.DataFields.FieldByName("LOGOID").Value = "Firma Kodu";
                            // Cari.DataFields.FieldByName("WEB_URL").Value = sqlreaders["CONTACT"];// "www web sitesi";
                            // Cari.DataFields.FieldByName("DISTRICT").Value = sqlreaders["TITLE"];
                            // Cari.DataFields.FieldByName("TELEPHONE2").Value =  sqlreaders["TELEPHONE2"];
                            //   Cari.DataFields.FieldByName("TAX_OFFICE_CODE").Value =  sqlreaders["TAX_OFFICE_CODE"];;// "Veri Dairesi Kodu";
                            //  Cari.DataFields.FieldByName("BANK_NAMES1").Value = sqlreaders["BANKAADI"];//= "BANK_ID1";

                            //= "BANK_TITLE1";
                            //Cari.DataFields.FieldByName("BANK_TITLE1").Value = sqlreaders["VERGI_NO"];//= "BANK_TITLE1";
                            //Cari.DataFields.FieldByName("BANK_ID2").Value = sqlreaders["VERGI_NO"];//= "BANK_ID2";
                            //Cari.DataFields.FieldByName("BANK_TITLE2").Value = sqlreaders["VERGI_NO"];//= "BANK_TITLE2";

                            //Cari.DataFields.FieldByName("BANK_ACCOUNT1").Value = "BANK_ACCOUNT1";
                            //Cari.DataFields.FieldByName("BANK_ACCOUNT2").Value = "BANK_ACCOUNT2";



                            //if (sqlreaders["SAHIS_SIRKETI"].ToString() == "")
                            //{
                            //    Cari.DataFields.FieldByName("PERSCOMPANY").Value = 1;
                            //    Cari.DataFields.FieldByName("TCKNO").Value = sqlreaders["TC_KIMLIK_NO"];
                            //}

                            Cari.DataFields.FieldByName("PURCHBRWS").Value      = 1;
                            Cari.DataFields.FieldByName("SALESBRWS").Value      = 1;
                            Cari.DataFields.FieldByName("IMPBRWS").Value        = 1;
                            Cari.DataFields.FieldByName("EXPBRWS").Value        = 1;
                            Cari.DataFields.FieldByName("FINBRWS").Value        = 1;
                            Cari.DataFields.FieldByName("DATA_REFERENCE").Value = "~";

                            ValidateErrors err = Cari.ValidateErrors;
                            if (Cari.Post())
                            {
                                int      lastLogicalRef = Cari.DataFields.FieldByName("INTERNAL_REFERENCE").Value;
                                DateTime dt             = Convert.ToDateTime(DateTime.Now.ToShortDateString());

                                using (SqlConnection myConnectionUp = new SqlConnection(_GLOBAL_PARAMETERS._CONNECTIONSTRING_ERP.ToString()))
                                {
                                    myConnectionUp.Open();
                                    SqlCommand myCommandUp = new SqlCommand();
                                    myCommandUp.Connection  = myConnectionUp;
                                    myCommandUp.CommandText = "update dbo.LG_XT1015_" + _SIRKET_NO + " set EvrakAciklama='İŞLEM OK',YeniTedarikciFormu=1,WPPisahlaki=1,VergiLevhasi=1 ,TicaretSicilGazetesi=1,imzaSirkuleri=1,BankaBilgileri=1,EvrakTamTarihi=@EvrakTamTarihi,EvrakMail=@EvrakMail  where  PARLOGREF=@PARLOGREF";
                                    myCommandUp.Parameters.AddWithValue("@PARLOGREF", lastLogicalRef);
                                    myCommandUp.Parameters.AddWithValue("@EvrakTamTarihi", dt.ToString("yyyy.MM.dd").ToString());
                                    myCommandUp.Parameters.AddWithValue("@EvrakMail", EVRAK_MAIL);

                                    myCommandUp.ExecuteReader(CommandBehavior.CloseConnection);
                                }

                                EVRAK_MAIL = "";

                                //string itemCode = sqlreaders["CODE"].ToString ();
                                //string[] OitemCode = itemCode.Split('-');
                                //if (OitemCode[2].Length != 4) OitemCode[2] = OitemCode[2].ToString().Substring(0, 4).ToString();
                                //if (OitemCode[2] != null && OitemCode[2].Length == 4)
                                //{
                                //    itemCodes += OitemCode[0] + "-" + OitemCode[1] + "-" + OitemCode[2];
                                //}
                                //   CreateGlCard(_firmNo,  CODE , sqlreaders["UNVANI"].ToString());

                                BR_CARI_BILGI = "FİRMA EKLENDİ";
                                using (SqlConnection myConnectionUp = new SqlConnection(_GLOBAL_PARAMETERS._CONNECTIONSTRING_MDB.ToString()))
                                {
                                    myConnectionUp.Open();
                                    SqlCommand myCommandUp = new SqlCommand();
                                    myCommandUp.Connection  = myConnectionUp;
                                    myCommandUp.CommandText = "update dbo.ADM_PAZARLAMA_SIRKETI set LOGO_DURUMU='AÇILDI' where  ID=@ID";
                                    myCommandUp.Parameters.AddWithValue("@ID", ID);
                                    myCommandUp.ExecuteReader(CommandBehavior.CloseConnection);
                                }
                            }
                            else
                            {
                                // Console.WriteLine("{0} firması eklenemedi.", "Firma Adı");
                                BR_CARI_BILGI = "FİRMA EKLENEMEDİ";
                                for (int i = 0; i < err.Count; i++)
                                {
                                    Console.WriteLine("{0} – {1};", err[i].Error, err[i].ID);
                                }
                            }
                        }
                    }
                    Cari = null;
                }
                sqlreaders.Close();
                cmd.Connection.Close();
            }
        }
Exemplo n.º 3
0
        private void MUSTERI_SAHIS_EKLE(int ID, string CODE)
        {
            string itemCodes = string.Empty;

            using (SqlConnection myConnections = new SqlConnection(_GLOBAL_PARAMETERS._CONNECTIONSTRING_MDB.ToString()))
            {
                myConnections.Open();
                SqlCommand myCommands = new SqlCommand();
                myCommands.Connection  = myConnections;
                myCommands.CommandText = "SELECT  *  from dbo.ADM_MUSTERI where  ID=@ID";
                myCommands.Parameters.AddWithValue("@ID", ID);
                SqlDataReader sqlreaders = myCommands.ExecuteReader(CommandBehavior.CloseConnection);
                while (sqlreaders.Read())
                {
                    string             BR_CARI_BILGI = string.Empty;
                    UnityObjects.IData Cari          = default(UnityObjects.IData);
                    if (_GLOBAL_PARAMETERS.Global.UnityApp.Connected)
                    {
                        Query  CARI_SORGULA = _GLOBAL_PARAMETERS.Global.UnityApp.NewQuery();
                        string CARI_KONTROL = string.Empty;
                        CARI_SORGULA.Statement = " SELECT  TAXNR  FROM  dbo.LG_" + _GLOBAL_PARAMETERS._SIRKET_NO + "_CLCARD  WHERE (dbo.LG_" + _GLOBAL_PARAMETERS._SIRKET_NO + "_CLCARD.CODE='" + sqlreaders["VERGI_NO"] + "')";
                        if (CARI_SORGULA.OpenDirect())
                        {
                            Cari = _GLOBAL_PARAMETERS.Global.UnityApp.NewDataObject(UnityObjects.DataObjectType.doAccountsRP);
                            Cari.New();
                            Cari.DataFields.FieldByName("ACCOUNT_TYPE").Value = 3;
                            Cari.DataFields.FieldByName("CODE").Value         = CODE;
                            Cari.DataFields.FieldByName("TITLE").Value        = sqlreaders["M_UNVANI"];
                            Cari.DataFields.FieldByName("ADDRESS1").Value     = sqlreaders["M_ADRESI"];
                            //Cari.DataFields.FieldByName("ADDRESS2").Value = sqlreaders["ADDRESS2"];
                            // Cari.DataFields.FieldByName("DISTRICT").Value = sqlreaders["TITLE"];
                            Cari.DataFields.FieldByName("TOWN").Value    = sqlreaders["M_ILCE"];// "İlçe";
                            Cari.DataFields.FieldByName("CITY").Value    = sqlreaders["M_IL"];;
                            Cari.DataFields.FieldByName("COUNTRY").Value = sqlreaders["M_ULKE"];;
                            //Cari.DataFields.FieldByName("POSTAL_CODE").Value = sqlreaders["POSTAL_CODE"]; ;//"Posta Kodu";
                            Cari.DataFields.FieldByName("TELEPHONE1").Value = sqlreaders["M_TELEFON"];
                            // Cari.DataFields.FieldByName("TELEPHONE2").Value =  sqlreaders["TELEPHONE2"];
                            Cari.DataFields.FieldByName("FAX").Value        = sqlreaders["M_FAX"];
                            Cari.DataFields.FieldByName("TAX_ID").Value     = sqlreaders["VERGI_NO"].ToString().Replace(" ", "");; // "Vergi No";
                            Cari.DataFields.FieldByName("TAX_OFFICE").Value = sqlreaders["VERGI_DAIRESI"];;                        //"Vergi Dairesi";
                            // Cari.DataFields.FieldByName("TAX_OFFICE_CODE").Value =  sqlreaders["TAX_OFFICE_CODE"];;// "Veri Dairesi Kodu";
                            // Cari.DataFields.FieldByName("CONTACT").Value =  sqlreaders["CONTACT"];// "İsim Soyisim";
                            Cari.DataFields.FieldByName("E_MAIL").Value = sqlreaders["M_EMAIL"]; //"E- Posta";
                            // Cari.DataFields.FieldByName("WEB_URL").Value = sqlreaders["CONTACT"];// "www web sitesi";
                            // Cari.DataFields.FieldByName("GL_CODE").Value = sqlreaders["CONTACT"];// CreateGlCard(FIRMA_KODU, CODE, TITLE);// "Muhasebe Numarası";
                            //Cari.DataFields.FieldByName("SUBSCRIBER_EXT").Value = "Ekstra bilgi";
                            //Cari.DataFields.FieldByName("LOGOID").Value = "Firma Kodu";

                            Cari.DataFields.FieldByName("PERSCOMPANY").Value    = 1;
                            Cari.DataFields.FieldByName("TCKNO").Value          = sqlreaders["TC_KIMLIK_NO"];
                            Cari.DataFields.FieldByName("PURCHBRWS").Value      = 1;
                            Cari.DataFields.FieldByName("SALESBRWS").Value      = 1;
                            Cari.DataFields.FieldByName("IMPBRWS").Value        = 1;
                            Cari.DataFields.FieldByName("EXPBRWS").Value        = 1;
                            Cari.DataFields.FieldByName("FINBRWS").Value        = 1;
                            Cari.DataFields.FieldByName("PURCHBRWS").Value      = 1;
                            Cari.DataFields.FieldByName("SALESBRWS").Value      = 1;
                            Cari.DataFields.FieldByName("IMPBRWS").Value        = 1;
                            Cari.DataFields.FieldByName("EXPBRWS").Value        = 1;
                            Cari.DataFields.FieldByName("FINBRWS").Value        = 1;
                            Cari.DataFields.FieldByName("DATA_REFERENCE").Value = "~";

                            ValidateErrors err = Cari.ValidateErrors;
                            if (Cari.Post())
                            {
                                BR_CARI_BILGI = "FİRMA EKLENDİ";
                                using (SqlConnection myConnectionUp = new SqlConnection(_GLOBAL_PARAMETERS._CONNECTIONSTRING_MDB.ToString()))
                                {
                                    myConnectionUp.Open();
                                    SqlCommand myCommandUp = new SqlCommand();
                                    myCommandUp.Connection  = myConnectionUp;
                                    myCommandUp.CommandText = "update dbo.ADM_MUSTERI set LOGO_DURUMU='AÇILDI' where  ID=@ID";
                                    myCommandUp.Parameters.AddWithValue("@ID", ID);
                                    myCommandUp.ExecuteReader(CommandBehavior.CloseConnection);
                                }

                                string   itemCode  = CODE;// sqlreaders["CODE"].ToString();
                                string[] OitemCode = itemCode.Split('-');
                                if (OitemCode[2].Length != 4)
                                {
                                    OitemCode[2] = OitemCode[2].ToString().Substring(0, 4).ToString();
                                }
                                if (OitemCode[2] != null && OitemCode[2].Length == 4)
                                {
                                    itemCodes += OitemCode[0] + "-" + OitemCode[1] + "-" + OitemCode[2];
                                }
                                CreateGlCard(_GLOBAL_PARAMETERS._SIRKET_NO, "740.0" + OitemCode[0] + ".001." + OitemCode[2], sqlreaders["UNVANI"].ToString()); // 120  son 4 hanesini araştır
                                CreateGlCard(_GLOBAL_PARAMETERS._SIRKET_NO, "601.0" + OitemCode[0] + ".001." + OitemCode[2], sqlreaders["UNVANI"].ToString());
                                CreateGlCard(_GLOBAL_PARAMETERS._SIRKET_NO, "600.0" + OitemCode[0] + ".001." + OitemCode[2], sqlreaders["UNVANI"].ToString());
                                CreateGlCard(_GLOBAL_PARAMETERS._SIRKET_NO, "610.0" + OitemCode[0] + ".001." + OitemCode[2], sqlreaders["UNVANI"].ToString());
                                CreateGlCard(_GLOBAL_PARAMETERS._SIRKET_NO, "611.0" + OitemCode[0] + ".001." + OitemCode[2], sqlreaders["UNVANI"].ToString());
                            }
                            else
                            {
                                // Console.WriteLine("{0} firması eklenemedi.", "Firma Adı");
                                BR_CARI_BILGI = "FİRMA EKLENEMEDİ";
                                for (int i = 0; i < err.Count; i++)
                                {
                                    Console.WriteLine("{0} – {1};", err[i].Error, err[i].ID);
                                }
                            }
                        }
                    }
                    Cari = null;
                }
                sqlreaders.Close();
                myCommands.Connection.Close();
                myConnections.Close();
            }
        }
Exemplo n.º 4
0
        private void BTN_LOGO_SECILENLERI_AKATAR_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            UnityObjects.IData arpVoucher = default(UnityObjects.IData);
            UnityObjects.IData invObj = default(UnityObjects.IData);
            UnityObjects.Lines arpVoucherLines = default(UnityObjects.Lines);
            UnityObjects.Lines arpPaymentLines = default(UnityObjects.Lines);
            UnityObjects.Query UnityQuery = default(UnityObjects.Query);
            int      i, m, k, cnt;
            int      groupedRowCount = 0;
            int      sign = 0;
            DateTime ficheDate;
            DateTime tempdate;


            for (int j = 0; j <= workTable.Rows.Count - 1; j++)
            {
                if ((bool)workTable.Rows[j]["DECPRDIFF"] == true)
                {
                    arpVoucher = _GLOBAL_PARAMETERS.Global.UnityApp.NewDataObject(UnityObjects.DataObjectType.doARAPVoucher);
                    arpVoucher.New();
                    arpVoucher.DataFields.FieldByName("NUMBER").Value = "~"; //workTable.Rows[j]["DOCODE"].ToString();  logo numara çakışmasından dolayı bu alanı düzelttik
                    ficheDate = (DateTime)workTable.Rows[j]["DATE_"];
                    arpVoucher.DataFields.FieldByName("DATE").Value            = ficheDate;
                    arpVoucher.DataFields.FieldByName("TYPE").Value            = 5;
                    arpVoucher.DataFields.FieldByName("CURRSEL_TOTALS").Value  = 1;
                    arpVoucher.DataFields.FieldByName("CURRSEL_DETAILS").Value = 1;
                    arpVoucher.DataFields.FieldByName("DATE_CREATED").Value    = DateTime.Now.ToShortDateString();
                    arpVoucher.DataFields.FieldByName("NOTES1").Value          = workTable.Rows[j]["DOCODE"].ToString();//= "FT-" + workTable.Rows[j]["DOCODE"].ToString() + " " + workTable.Rows[j]["NOTES1"].ToString();
                    arpVoucher.DataFields.FieldByName("DATA_REFERENCE").Value  = "~";
                    arpVoucherLines = arpVoucher.DataFields.FieldByName("TRANSACTIONS").Lines;
                    ///''''VİRMAN FİŞİ SATIR 1'''''''''''''''''''''''''''''''''''''''
                    ///
                    if (arpVoucherLines.AppendLine())
                    {
                        arpVoucherLines[0].FieldByName("ARP_CODE").Value       = btn_CARI_II.EditValue;
                        arpVoucherLines[0].FieldByName("GL_CODE1").Value       = GL_CODE_II;//clientAcc_2;
                        arpVoucherLines[0].FieldByName("CURR_TRANS").Value     = 0;
                        arpVoucherLines[0].FieldByName("CURRSEL_TRANS").Value  = 1;
                        arpVoucherLines[0].FieldByName("TC_XRATE").Value       = 1;
                        arpVoucherLines[0].FieldByName("TC_AMOUNT").Value      = Convert.ToDouble(workTable.Rows[j]["TOTAL"].ToString());
                        arpVoucherLines[0].FieldByName("DESCRIPTION").Value    = "FT-" + workTable.Rows[j]["DOCODE"].ToString() + " " + workTable.Rows[j]["NOTES1"].ToString();
                        arpVoucherLines[0].FieldByName("DATA_REFERENCE").Value = "~";

                        switch (workTable.Rows[j]["TYPE"].ToString())
                        {
                        case "6":
                        case "7":
                        case "8":
                        case "9":
                        case "10":
                            arpVoucherLines[0].FieldByName("DEBIT").Value = Convert.ToDouble(workTable.Rows[j]["TOTAL"].ToString());
                            sign = 1;
                            break;

                        default:
                            arpVoucherLines[0].FieldByName("CREDIT").Value = Convert.ToDouble(workTable.Rows[j]["TOTAL"].ToString());
                            sign = 0;;
                            break;
                        }
                    }
                    arpPaymentLines = arpVoucherLines._Item[0].FieldByName("PAYMENT_LIST").Lines;

                    if (arpPaymentLines.AppendLine())
                    {
                        if (workTable.Rows[j]["DUEDATE"].ToString() != "")
                        {
                            tempdate = Convert.ToDateTime(workTable.Rows[j]["DUEDATE"].ToString());
                            arpPaymentLines[0].FieldByName("MODULENR").Value         = 5;
                            arpPaymentLines[0].FieldByName("DATE").Value             = tempdate.ToShortDateString();
                            arpPaymentLines[0].FieldByName("TRCODE").Value           = 5;
                            arpPaymentLines[0].FieldByName("SIGN").Value             = sign;
                            arpPaymentLines[0].FieldByName("TOTAL").Value            = Convert.ToDouble(workTable.Rows[j]["TOTAL"].ToString());
                            arpPaymentLines[0].FieldByName("DISCTRDELLIST").Value    = 0;
                            arpPaymentLines[0].FieldByName("PAY_NO").Value           = 1;
                            arpPaymentLines[0].FieldByName("MODIFIED").Value         = 1;
                            arpPaymentLines[0].FieldByName("PROCDATE").Value         = ficheDate;
                            arpPaymentLines[0].FieldByName("DISCOUNT_DUEDATE").Value = tempdate.ToShortDateString();
                            arpPaymentLines[0].FieldByName("TRCURR").Value           = 0;
                            arpPaymentLines[0].FieldByName("TRRATE").Value           = 1;
                        }
                    }

                    // ''''VİRMAN FİŞİ SATIR 2'''''''''''''''''''''''''''''''''''''''

                    if (arpVoucherLines.AppendLine())
                    {
                        arpVoucherLines[1].FieldByName("ARP_CODE").Value      = btn_CARI_I.EditValue;
                        arpVoucherLines[1].FieldByName("GL_CODE1").Value      = GL_CODE_I;// clientAcc_1;
                        arpVoucherLines[1].FieldByName("CURR_TRANS").Value    = 0;
                        arpVoucherLines[1].FieldByName("CURRSEL_TRANS").Value = 1;
                        arpVoucherLines[1].FieldByName("TC_XRATE").Value      = 1;
                        arpVoucherLines[1].FieldByName("TC_AMOUNT").Value     = Convert.ToDouble(workTable.Rows[j]["TOTAL"].ToString());
                        arpVoucherLines[1].FieldByName("DESCRIPTION").Value   = "FT-" + workTable.Rows[j]["DOCODE"].ToString() + " " + workTable.Rows[j]["NOTES1"].ToString();
                        switch (workTable.Rows[j]["TYPE"].ToString())
                        {
                        case "6":
                        case "7":
                        case "8":
                        case "9":
                        case "10":
                            arpVoucherLines[1].FieldByName("CREDIT").Value = Convert.ToDouble(workTable.Rows[j]["TOTAL"].ToString());
                            break;

                        default:
                            arpVoucherLines[1].FieldByName("DEBIT").Value = Convert.ToDouble(workTable.Rows[j]["TOTAL"].ToString());
                            break;
                        }
                        arpVoucherLines[1].FieldByName("DATA_REFERENCE").Value = "~";
                    }

                    arpPaymentLines = arpVoucherLines._Item[1].FieldByName("PAYMENT_LIST").Lines;
                    if (arpPaymentLines.AppendLine())
                    {
                        if (workTable.Rows[j]["DUEDATE"].ToString() != "")
                        {
                            tempdate = Convert.ToDateTime(workTable.Rows[j]["DUEDATE"].ToString());
                            arpPaymentLines[0].FieldByName("MODULENR").Value         = 5;
                            arpPaymentLines[0].FieldByName("DATE").Value             = tempdate.ToShortDateString();
                            arpPaymentLines[0].FieldByName("TRCODE").Value           = 5;
                            arpPaymentLines[0].FieldByName("SIGN").Value             = sign;
                            arpPaymentLines[0].FieldByName("TOTAL").Value            = Convert.ToDouble(workTable.Rows[j]["TOTAL"].ToString());
                            arpPaymentLines[0].FieldByName("DISCTRDELLIST").Value    = 0;
                            arpPaymentLines[0].FieldByName("PAY_NO").Value           = 1;
                            arpPaymentLines[0].FieldByName("MODIFIED").Value         = 1;
                            arpPaymentLines[0].FieldByName("PROCDATE").Value         = ficheDate;
                            arpPaymentLines[0].FieldByName("DISCOUNT_DUEDATE").Value = tempdate.ToShortDateString();
                            arpPaymentLines[0].FieldByName("TRCURR").Value           = 0;
                            arpPaymentLines[0].FieldByName("TRRATE").Value           = 1;
                        }
                    }

                    // arpVoucher.ExportToXML("","c:\temp\aa.xml");
                    if (arpVoucher.Post())
                    {
                        //  UnityObjects.IData invObj = default(UnityObjects.IData);
                        Query  Querys       = _GLOBAL_PARAMETERS.Global.UnityApp.NewQuery();
                        string Query_String = " SELECT  LOGICALREF  FROM  dbo.LG_" + _GLOBAL_PARAMETERS._SIRKET_NO + "_01_INVOICE  where (FICHENO='" + workTable.Rows[j]["FICHENO"].ToString() + "')";
                        Querys.Statement = Query_String;
                        if (Querys.OpenDirect())
                        {
                            Querys.First();
                            switch (workTable.Rows[j]["TYPE"].ToString())
                            {
                            case "6":
                            case "7":
                            case "8":
                            case "9":
                            case "10":
                                invObj = _GLOBAL_PARAMETERS.Global.UnityApp.NewDataObject(UnityObjects.DataObjectType.doSalesInvoice);
                                break;

                            default:
                                invObj = _GLOBAL_PARAMETERS.Global.UnityApp.NewDataObject(UnityObjects.DataObjectType.doPurchInvoice);
                                break;
                            }
                            if (invObj.Read(Querys.QueryFields[0].Value))
                            {
                                invObj.DataFields.FieldByName("TRADING_GRP").Value = "FAC";

                                workTable.Rows[j]["DURUMU"] = "AKTARILDI";
                            }
                            invObj.Post();
                        }
                    }
                    else
                    {
                        if (arpVoucher.ValidateErrors.Count > 0)
                        {
                            for (int ix = 0; ix <= arpVoucher.ValidateErrors.Count - 1; ix++)
                            {
                                MessageBox.Show("Error code : " + (arpVoucher.ValidateErrors[ix].ID) + "Error code : " + (char)10 + arpVoucher.ValidateErrors[ix].Error.ToString());
                            }
                        }
                    }
                }
            }
        }