public partial class StorageIn : DepotSystem.
FormShow
{
MySqlConnection con = [Link];
private delegate void CarrierDelegate();
[Link] lastDrive;
const string formatDate = "dd/MM/yyyy HH:mm";
private List<[Link]> cPrice;
private bool carrierLoaded = false;
private List<[Link]> lc = new
List<[Link]>();
private [Link] eCurrent = null;
private [Link] eOriginal = new
[Link]();
public StorageIn()
{
InitializeComponent();
[Link](new [Link]() { Name = "Fantasy",
Visible = true });
[Link](new [Link]() { Name = "Name", Visible
= true });
[Link](new [Link]() { Name = "Cnpj", Visible
= true });
LoadType();
[Link] = [Link](formatDate);
new [Link](CarrierInvoke).Start();
LoadOperations();
}
private void LoadType()
{
[Link] = "InitialThird";
[Link] = "InitialThird";
[Link] = new [Link]();
List<[Link]> typeCopy = [Link]();
[Link] = typeCopy;
[Link] = -1;
private void CarrierInvoke()
{
if ([Link])
{
[Link](new CarrierDelegate(LoadCarrier));
// [Link]();
}
else
{
LoadCarrier();
private [Link] Log()
{
[Link] storageIn = new
[Link]();
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
if ([Link])
[Link] = "FATURADO";
else if ([Link])
[Link] = "ENTRADA";
else if ([Link])
[Link] = "SAIDA";
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
return storageIn;
}
private void LoadOperations()
{
[Link] = "CodeThird";
[Link] = "Description";
[Link] = new [Link]();
List<[Link]> opCopy = [Link](x =>
[Link] == [Link]).ToList();
[Link] = opCopy;
[Link] = -1;
private void LoadCarrier()
{
[Link] = lc;
[Link]();
[Link] = "Fantasy";
[Link] = "Cnpj";
[Link] = [Link]();
[Link] = -1;
[Link]();
private void txtDocument_Validating(object sender, CancelEventArgs e)
{
if ()
{
lastDrive = [Link]([Link], true);
if (lastDrive == null)
{
[Link]();
[Link]();
[Link]();
}
else
{
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
}
}
Driver();
}
private void txtCc_Validating(object sender, CancelEventArgs e)
{
if ([Link]([Link]))
return;
try
{
[Link]();
MySqlCommand cmd = new MySqlCommand("select EXISTS(select Cc from
Storage where IdConfig = ?IdConfig and Cc = ?Cc and GateOut is null)", con);
[Link]("?IdConfig", [Link]);
[Link]("?Cc", [Link]);
if ((long)[Link]() > 0)
{
[Link]("Unidade " + [Link] + " ativa no
terminal", [Link], "Aviso", false, 2000, null);
[Link]();
}
}
catch (Exception ex)
{
[Link]([Link](), "Error");
}
finally
{
[Link]();
}
}
private void GetPriceTable(string priceName)
{
if ([Link](priceName))
return;
try
{
[Link]();
MySqlCommand cmd = new MySqlCommand("select TypeInitial, Storage,
Transhipment, Daily, StorageFull, DailyFull from PriceStorage where PriceName = ?
PriceName and IdConfig = ?IdConfig", con);
[Link]("?IdConfig", [Link]);
[Link]("?PriceName", priceName);
MySqlDataReader l = [Link]();
cPrice = new List<[Link]>();
while ([Link]())
{
[Link] p = new [Link]();
[Link] = l["Daily"] == [Link] ? (short)1 :
(short)l["Daily"];
[Link] = l["TypeInitial"] == [Link] ? "ND" :
(string)l["TypeInitial"];
[Link] = l["Storage"] == [Link] ? 0m :
(decimal)l["Storage"];
[Link] = l["Transhipment"] == [Link] ? 0m :
(decimal)l["Transhipment"];
[Link] = l["DailyFull"] == [Link] ? (short)1 :
(short)l["DailyFull"];
[Link] = l["StorageFull"] == [Link] ? 0m :
(decimal)l["StorageFull"];
[Link](p);
}
[Link]();
}
catch (Exception ex)
{
[Link]([Link], "Error");
}
finally
{
[Link]();
}
}
private void cboCarrier_Validating(object sender, CancelEventArgs e)
{
cPrice = null;
if ([Link] > 0 && [Link] != null)
{
[Link](sender, carrierLoaded);
[Link] carrierValue = [Link];
if (carrierValue != null && !
[Link]([Link]))
{
GetPriceTable([Link]);
}
}
else
[Link] = -1;
Carrier();
CalculteTariff();
}
private void CalculteTariff()
{
if (cPrice != null && [Link] != null &&
[Link] != null && [Link] != -1)
{
[Link] t = [Link](x => [Link] ==
[Link]()).FirstOrDefault();
if (t != null)
{
[Link] op =
[Link]([Link],
[Link]());
if ([Link] == [Link] &&
[Link] == "CHEIO")
{
[Link] = [Link]();
[Link] = [Link]();
if( && !
[Link]([Link]))
{
decimal tmp = ([Link]([Link]) *
[Link]([Link]) / 100) + [Link];
[Link] = [Link]("N2");
}
return;
}
if ([Link] == [Link] &&
[Link] == "VAZIO")
{
[Link] = [Link]();
[Link] = [Link]();
return;
}
if ([Link] == [Link])
{
[Link] = [Link]();
[Link] = "1";
}
}
}
else
{
[Link]();
[Link]();
}
private void Carrier()
{
if ([Link] == null)
[Link](cboCarrier, "Obrigatório o preenchimento da
transportadora");
else
[Link](cboCarrier);
}
private void Plate()
{
if ([Link]([Link]))
[Link](txtPlate, "Obrigatório o preenchimento da
placa");
else
[Link](txtPlate);
}
private void Price()
{
if ([Link]([Link]))
[Link](txtPrice, "Valor não localizado");
else
[Link](txtPrice);
}
private void CcUnits()
{
if ([Link]([Link]))
[Link](txtCc, "Container não informado");
else
[Link](txtCc);
}
private void TypeUnits()
{
if ([Link] == null)
[Link](cboType, "Tipo não informado");
else
[Link](cboType);
}
private void Operations()
{
if ([Link] == null)
[Link](cboOperation, "Operação não informada");
else
[Link](cboOperation);
}
private void Driver()
{
if ([Link]([Link]))
[Link](txtDriver, "Motorista não informado");
else
[Link](txtDriver);
}
private void Days()
{
if ([Link]([Link]))
[Link](txtDaily, "Tempo de diaria não localizado");
else
[Link](txtDaily);
}
private bool ValidateField()
{
CcUnits();
TypeUnits();
Driver();
Carrier();
Plate();
Price();
Days();
Operations();
if ([Link])
{
[Link]("Favor verificar todas as criticas", "Aviso",
[Link], [Link]);
return false;
}
return true;
private void ClearAll()
{
cPrice = null;
[Link](this);
[Link]();
}
private void btoSave_Click(object sender, EventArgs e)
{
if (!ValidateField()) return;
MySqlTransaction myTrans = null;
try
{
[Link]();
myTrans = [Link]();
MySqlCommand cmd = new MySqlCommand("select EXISTS(select * from
Storage where IdConfig = ?IdConfig and Cc = ?Cc and GateOut is null)", con);
[Link] = myTrans;
[Link]("?IdConfig", [Link]);
[Link]("?Cc", [Link]);
if ((long)[Link]() == 0)
{
MySqlCommand cmdEir = new MySqlCommand("NumberEir", con);
[Link] = [Link];
[Link]("?Id", [Link]);
[Link](new MySqlParameter("?EirNumber",
MySqlDbType.Int32));
[Link]["?EirNumber"].Direction =
[Link];
[Link]();
int nEir = (Int32)[Link]["?EirNumber"].Value;
[Link] = "insert into Storage (IdConfig, GateIn, EirIn,
Cc, Type, Operation, CarrierIn, Paymment, TypePayIn, DocumentIn, PlateIn, PhoneIn,
DriverIn, Daily, Price, RemarksIn, UserIn, AdValorem, SumNf, PlugReefer, Modality,
DeliveryEmpty ) values (?IdConfig, ?GateIn, ?EirIn, ?Cc, ?Type, ?Operation, ?
CarrierIn, ?Paymment, ?TypePayIn, ?DocumentIn, ?PlateIn, ?PhoneIn, ?DriverIn, ?
Daily, ?Price, ?RemarksIn, ?UserIn, ?AdValorem, ?SumNf, ?PlugReefer, ?Modality, ?
DeliveryEmpty) ";
[Link]("?GateIn",
[Link]([Link]) ? [Link] :
[Link]([Link]));
[Link]("?EirIn", nEir);
[Link]("?Type", [Link]);
[Link]("?Operation",
[Link]);
[Link]("?CarrierIn",
[Link]([Link](), "$", [Link]));
if ([Link])
[Link]("?Paymment", 0);
else if ([Link])
[Link]("?Paymment", 1);
else if ([Link])
[Link]("?Paymment", 2);
[Link]("?TypePayIn", [Link]
> -1 ? [Link] : null);
[Link]("?DocumentIn", [Link]);
[Link]("?PlateIn", [Link]);
[Link]("?PhoneIn", [Link]);
[Link]("?DriverIn", [Link]);
[Link]("?Daily", [Link]);
[Link]("?Price",
[Link]([Link]));
[Link]("?RemarksIn", [Link]);
[Link]("?DeliveryEmpty",
[Link]);
[Link]("?UserIn", [Link]);
[Link]("?AdValorem",
[Link]([Link]) ? (decimal?)null :
[Link]( [Link]));
[Link]("?SumNf",
[Link]([Link]) ? (decimal?)null :
[Link]([Link]));
[Link]("?PlugReefer", [Link]);
[Link]("?Modality", [Link]);
[Link]();
long id = [Link];
eCurrent = Log();
[Link](con, eOriginal, eCurrent,
[Link], "STORAGE_IN", myTrans);
[Link]();
[Link]();
[Link](true, (int)id, [Link], con,
false, [Link]([Link]["StorageInTerm"]));
[Link]();
}
else
{
[Link]("Unidade " + [Link] + " ativa no
terminal", [Link], "Aviso", false, 2000, null);
[Link]();
}
}
catch (Exception ex)
{
[Link]();
[Link]([Link](), "Error");
}
finally
{
[Link]();
}
private void cboType_Validating(object sender, CancelEventArgs e)
{
CalculteTariff();
TypeUnits();
}
private void cboOperation_Validating(object sender, CancelEventArgs e)
{
CalculteTariff();
Operations();
}
private void txtCc_Enter(object sender, EventArgs e)
{
if ([Link] == 11)
{
ClearAll();
}
}
private void txtPlate_Validating(object sender, CancelEventArgs e)
{
Plate();
}
private void cboCarrier_KeyDown(object sender, KeyEventArgs e)
{
if([Link] == Keys.F12)
{
LoadCarrier();
}
}
private void cboEmptyFull_SelectionChangeCommitted(object sender, EventArgs e)
{
if([Link]=="CHEIO")
{
[Link] = true;
[Link] = true;
[Link] = true;
[Link] = true;
[Link] = true;
}
else
{
[Link] = false;
[Link] = false;
[Link] = false;
[Link] = false;
[Link] = false;
}
CalculteTariff();
}
private Color BorderColor = [Link];
private void PaintGroup(GroupBox grp, PaintEventArgs e)
{
Size FontSize = [Link]([Link],
[Link]);
Rectangle rec = new Rectangle([Link].Y,
[Link] / 2,
[Link] - 1,
[Link] - 1 -
[Link] / 2);
[Link](new Pen(BorderColor), rec);
[Link](new SolidBrush([Link]),
new Rectangle(6, 0, [Link], [Link]));
//text
[Link]([Link], [Link],
new Pen([Link]).Brush, 6, 0);
}
private void groupBox2_Paint(object sender, PaintEventArgs e)
{
PaintGroup(groupBox2, e);
// [Link]([Link]);
// Rectangle Rtg_LT = new Rectangle();
// Rectangle Rtg_RT = new Rectangle();
// Rectangle Rtg_LB = new Rectangle();
// Rectangle Rtg_RB = new Rectangle();
// Rtg_LT.X = 0; Rtg_LT.Y = 7; Rtg_LT.Width = 10; Rtg_LT.Height = 10;
// Rtg_RT.X = [Link] - 11; Rtg_RT.Y = 7; Rtg_RT.Width = 10;
Rtg_RT.Height = 10;
// Rtg_LB.X = 0; Rtg_LB.Y = [Link] - 11; Rtg_LB.Width =
10; Rtg_LB.Height = 10;
// Rtg_RB.X = [Link] - 11; Rtg_RB.Y =
[Link] - 11; Rtg_RB.Width = 10; Rtg_RB.Height = 10;
// Color color = [Link](51, 94, 168);
// Pen Pen_AL = new Pen(color, 1);
// Pen_AL.Color = color;
// Brush brush = new HatchBrush([Link], color);
// [Link]([Link], [Link], brush, 6, 0);
// [Link](Pen_AL, Rtg_LT, 180, 90);
// [Link](Pen_AL, Rtg_RT, 270, 90);
// //[Link](Pen_AL, Rtg_LB, 90, 90);
// //[Link](Pen_AL, Rtg_RB, 0, 90);
//// [Link](Pen_AL, 5, 7, 6, 7);
// [Link](Pen_AL, [Link]([Link],
[Link]).Width + 3, 7, [Link] - 7, 7);
// [Link](Pen_AL, 0, 13, 0, [Link] - 7);
// [Link](Pen_AL, 6, [Link] - 1,
[Link] - 7, [Link] - 1);
// [Link](Pen_AL, [Link] - 1,
[Link] - 7, [Link] - 1, 13);
}
private void RdAvista_Click(object sender, EventArgs e)
{
if ([Link])
{
[Link] = true;
}
else
{
[Link] = false;
[Link] = -1;
}
private void groupBox3_Paint(object sender, PaintEventArgs e)
{
PaintGroup(groupBox3, e);
}
private void groupBox1_Paint(object sender, PaintEventArgs e)
{
PaintGroup(groupBox1, e);
}
}