SalInvoice.DataFields.FieldByName("TYPE").Value = 8;
SalInvoice.DataFields.FieldByName("NUMBER").Value = "~";
SalInvoice.DataFields.FieldByName("DATE").Value = DrFc.GetDateTime(2);
SalInvoice.DataFields.FieldByName("PROJECT_CODE").Value = DrFc.GetInt32(3);
SalInvoice.DataFields.FieldByName("AUXIL_CODE").Value = "Transit";
SalInvoice.DataFields.FieldByName("ARP_CODE").Value = DrFc.GetString(5);
SalInvoice.DataFields.FieldByName("GL_CODE").Value = "120.01.M001";
SalInvoice.DataFields.FieldByName("SOURCE_WH").Value = DrFc.GetInt32(3);
SalInvoice.DataFields.FieldByName("SOURCE_COST_GRP").Value = DrFc.GetString(4);
SalInvoice.DataFields.FieldByName("PAYMENT_CODE").Value = DrFc.GetString(6);
while (DrLn.Read())
{
UnityObjects.Lines SalInvoiceLines = SalInvoice.DataFields.FieldByName("TRANSACTIONS").Lines;
SalInvoiceLines.AppendLine();
SalInvoiceLines[m_LinCount].FieldByName("TYPE").Value = 0;
SalInvoiceLines[m_LinCount].FieldByName("MASTER_CODE").Value = DrLn.GetString(0);
SalInvoiceLines[m_LinCount].FieldByName("SOURCEINDEX").Value = DrFc.GetInt32(3);
SalInvoiceLines[m_LinCount].FieldByName("SOURCECOSTGRP").Value = DrFc.GetString(4);
SalInvoiceLines[m_LinCount].FieldByName("QUANTITY").Value = DrLn.GetDouble(2);
SalInvoiceLines[m_LinCount].FieldByName("PRICE").Value = DrLn.GetDouble(3);
SalInvoiceLines[m_LinCount].FieldByName("CURR_PRICE").Value = 160;
SalInvoiceLines[m_LinCount].FieldByName("UNIT_CODE").Value = DrLn.GetString(4);
SalInvoiceLines[m_LinCount].FieldByName("UNIT_CONV1").Value = 1;
SalInvoiceLines[m_LinCount].FieldByName("UNIT_CONV2").Value = 1;
SalInvoiceLines[m_LinCount].FieldByName("VAT_RATE").Value = DrLn.GetDouble(5);
SalInvoiceLines[m_LinCount].FieldByName("PROJECT_CODE").Value = DrFc.GetInt32(3);
m_LinCount++;
SalInvoiceLines.AppendLine(); //------------------------------------------------->>> Burası önemli
SalInvoiceLines[m_LinCount].FieldByName("TYPE").Value = 2;
SalInvoiceLines[m_LinCount].FieldByName("MASTER_CODE").Value = DrLn.GetDouble(6);
SalInvoiceLines[m_LinCount].FieldByName("SOURCEINDEX").Value = DrFc.GetInt32(3);
SalInvoiceLines[m_LinCount].FieldByName("SOURCECOSTGRP").Value = DrFc.GetString(4);
SalInvoiceLines[m_LinCount].FieldByName("DISCOUNT_RATE").Value = DrLn.GetDouble(6);
m_LinCount++;
}
if (!SalInvoice.Post())
{
if (SalInvoice.ValidateErrors.Count > 0)
{
for (int i = 0; i < SalInvoice.ValidateErrors.Count; i++)
{
LDL = new L_DYNAMICLOG();
LDL.ItemCode = "";
LDL.OperationDate_ = System.DateTime.Now;
LDL.FicheDate_ = DrFc.GetDateTime(2);
LDL.WhNo_ = Convert.ToInt32(DrFc.GetInt32(3));
LDL.Type = 7;
LDL.Str = SalInvoice.ValidateErrors.ID + " - " + SalInvoice.ValidateErrors.Error;
LDL.Total = 0;
ldc.L_DYNAMICLOGs.InsertOnSubmit(LDL);
MessageBox.Show(SalInvoice.ValidateErrors.ID + " - " + SalInvoice.ValidateErrors.Error);
}
}
}