Advertisement
Guest User

honza

a guest
Oct 24th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.70 KB | None | 0 0
  1. timer1.Enabled = false;
  2.  
  3.             UltraGridRow row = grPrequeue.ActiveRow;
  4.  
  5.             if (row == null || row.Index==-1)
  6.             {
  7.                 Tools.errMsg("Musíte vybrát řádek s dodávkou, kterou chcete přesunout do fronty (již je v závodu)!");
  8.                 return;
  9.             }
  10.  
  11.             if (!Tools.yesNo("Opravdu chcete auto " + (string)row.Cells["regnum"].Value + " přesunout do fronty (do závodu)?"))
  12.                 return;
  13.  
  14.             /*Pokud je vybraný "vrchní řádek, který má index -1"*/
  15.             if (row.Cells["scale11"].Value.ToString() == "0,00" || row.Cells["scale22"].Value.ToString() == "0,00")
  16.             {
  17.  
  18.                 MessageBox.Show("Není zvážené vozidlo", "Upozornění", MessageBoxButtons.OK, MessageBoxIcon.Information);
  19.                 return;
  20.             }
  21.  
  22.             /*Zde musíš dát váhu, jelikož pokud ji necháš dobře...kdo ví proč se váha z row vymaže....padá to při yesnoclick*/
  23.             float scaleWeight1 = float.Parse(row.Cells["scale11"].Value.ToString());
  24.             float scaleWeight2 = float.Parse(row.Cells["scale22"].Value.ToString());
  25.  
  26.  
  27.             // Create a new queue record and delete the prequeue record -> move delivery from prequeue to queue
  28.             DODelivery delivery = new DODelivery(row.Cells["deliveryid"].Value);
  29.             delivery.tStatus = 2;
  30.             delivery.tManuallyMovedToQueue = true;
  31.             delivery.tManuallyMovedToQueueOperator = ProgParam.selUserID;
  32.             delivery.saveToDB();
  33.  
  34.             string lineKey;
  35.             byte[] buff;
  36.             string sql;
  37.  
  38.             switch (delivery.tLineId)
  39.             {
  40.                 case 1:
  41.                     lineKey = "LONG_REGNUM";
  42.                     break;
  43.                 default:
  44.                     lineKey = "SHORT_REGNUM";
  45.                     break;
  46.             }
  47.  
  48.             try
  49.             {
  50.                 MemoryStream f = Tools.getPhotoFromCamera(lineKey);
  51.                 buff = new byte[Convert.ToInt32(f.Length)];
  52.                 f.Position = 0;
  53.                 f.Read(buff, 0, Convert.ToInt32(f.Length));
  54.                 f.Close();
  55.  
  56.                 MSSqlCommand MSCmd;
  57.                 SqlParameter[] Params = new SqlParameter[1];
  58.                 Params[0] = new SqlParameter("@data", buff);
  59.                 sql = "INSERT INTO dbo.deliveryphoto (deliveryid, data) VALUES (" + delivery.sqlDeliveryId + ", @data)";
  60.                 MSCmd = new MSSqlCommand(sql, Params, false);
  61.             }
  62.             catch { }
  63.  
  64.  
  65.             dsDeliveryMain.FillData(1, 0, 0);
  66.  
  67.  
  68.             // Check if an EVK delivery exists and create it after confirmation if not
  69.             if (String.IsNullOrEmpty(delivery.tEklDat) || String.IsNullOrEmpty(delivery.sEklLfNr))
  70.             {
  71.                 if (Tools.yesNo("Dodávka nemá vytvořenou fůru v EVK. Chcete ji vytvořit teď?"))
  72.                     if (Tools.CreateEVKDelivery(delivery))
  73.                         Tools.Info("V EVK byla úspěšně vytvořena dodávka " + delivery.EVKNum);
  74.                     else
  75.                         Tools.errMsg("Nebylo možno vytvořit dodávku v EVK!");
  76.             }
  77.  
  78.             int id = (int)delivery.oDeliveryId;
  79.             DOBMScale scale1 = new DOBMScale(id, UserControls.TableEnum.delivery, (int)UserControls.BmScaleRowNR.scale1);
  80.             scale1.oweight = scaleWeight1;
  81.             // scale.orownr = UserControls.BmScaleRowNR.scale1;
  82.             scale1.saveToDB();
  83.  
  84.             DOBMScale scale2 = new DOBMScale(id, UserControls.TableEnum.delivery, (int)UserControls.BmScaleRowNR.scale2);
  85.             scale2.oweight = scaleWeight2;
  86.             // scale.orownr = UserControls.BmScaleRowNR.scale1;
  87.             scale2.saveToDB();
  88.  
  89.             // Check if the delivery exists in the Sprecher queue in EVK and if not insert a new record there
  90.             ORASqlQuery Q;
  91.             ORASqlCommand Cmd;
  92.             bool exists;
  93.  
  94.             Q = new ORASqlQuery("SELECT COUNT(*) FROM shelitrans WHERE uebnr = " + delivery.sqlTakeoverId + " AND mandant = '10'");
  95.             if (Q.Read() && (!Q.Null(0)))
  96.                 exists = Q.getInt(0) > 0;
  97.             else
  98.                 exists = false;
  99.             Q.Close();
  100.  
  101.             if (!exists)
  102.                 Cmd = new ORASqlCommand("INSERT INTO shelitrans (uebnr, mandant, ekldat, ekllfnr, line, queue) " +
  103.                                          "VALUES (" + delivery.sqlTakeoverId + ", '" + ProgParam.selMandant + "', " + delivery.sqlEklDat + ", " +
  104.                                            delivery.sqlEklLfNr + ", " + delivery.sqlLineId + ", 'N')");
  105.  
  106.             timer1.Enabled = true;
  107.  
  108.             Tools.Info("Auto bylo přesunuto do fronty v závodu!");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement