示例#1
0
 void lvCustomers_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
 {
     Library.CustomerInfo c = ((CustomersAdapter)lvCustomers.Adapter).GetItem(e.Position);
     _custId = c.CustID;
     Log.Debug("lvCustomers_ItemClick", "_custId=" + _custId);
     if (_custId > 0)
     {
         Dismiss();
     }
 }
示例#2
0
        public void FillCustomerFields(Library.CustomerInfo c)
        {
            isCustChanging = true;

            tbCustDesc.Text    = c.Name;
            tbCustAddress.Text = c.CustAddress;
            //NE RAZKOMENTIRAI, NE MOJE DA SE LOADVA CUSTOMER PO KOD!!!!
            //tbCustCode.Text = c.Code;
            tbCustDebt.Text  = c.CustDebt.ToString();
            tbCustPhone.Text = c.CustPhone;

            isCustChanging = false;
        }
示例#3
0
        void LoadCustomerData(double custId)
        {
            Library.CustomerInfo c = Library.CustomerInfo.GetCustomer(Activity, custId);

            if (tbCustDesc != null)
            {
                FillCustomerFields(c);
                tbCustCode.Text = c.Code;
                FillInvoiceFields();

                if (CustomerChanged != null)
                {
                    CustomerChanged();
                }
            }
        }
示例#4
0
        public static CustomerInfo GetCustomer(Context ctx, string code)
        {
            CustomerInfo info = new CustomerInfo();

            if (code == "")
            {
                return(info);
            }

            using (IConnection conn = Sync.GetConnection(ctx))
            {
                IPreparedStatement ps = conn.PrepareStatement(@"SELECT id, cst_cod, cst_desc, cst_ypol, cst_kat_disc, 
					cst_tax_num, cst_trus_id, cst_addr, cst_city, cst_zip, cst_phone, cst_gsm, cst_comments
					FROM rcustomer WHERE cst_cod = :Code"                    );
                ps.Set("Code", code);

                IResultSet result = ps.ExecuteQuery();

                if (result.Next())
                {
                    info.CustID      = result.GetInt("id");
                    info.Code        = result.GetString("cst_cod");
                    info.Name        = result.GetString("cst_desc");
                    info.CustAddress = result.GetString("cst_addr");
                    info.CustTaxNum  = result.GetString("cst_tax_num");
                    info.CustDebt    = result.GetDouble("cst_ypol");
                    info.CustPhone   = result.GetString("cst_phone");

                    info.IsNew = false;
                }

                result.Close();
                ps.Close();
                conn.Commit();
                conn.Release();
            }

            return(info);
        }
示例#5
0
        public void Save(Context ctx)
        {
            CustomerInfo info = new CustomerInfo();

            using (IConnection conn = Sync.GetConnection(ctx))
            {
                IPreparedStatement ps;
                if (IsNew)
                {
                    ps = conn.PrepareStatement(@"
INSERT INTO rtrans_hed
(
cust_id, trans_date, vouch_id, voser_id, docnum, htrn_explanation
)
VALUES
(
:cst_id,
:htrn_date,
:vouch_id,
:voser_id,
:htrn_docnum,
:htrn_expl
)");
                    //SELECT last_insert_id();
                }
                else
                {
                    ps = conn.PrepareStatement(@"
UPDATE rtrans_hed SET
cust_id = :cst_id,
trans_date = :htrn_date,
vouch_id = :vouch_id,
voser_id = :voser_id,
docnum = :htrn_docnum,
htrn_explanation = :htrn_expl
WHERE id = :htrn_id");

                    ps.Set("htrn_id", HtrnId);
                }

                //ps.Set("comp_id", comp_id);
                //ps.Set("bran_id", bran_id);
                //ps.Set("store_id", store_id);
                //ps.Set("per_id", per_id);
                ps.Set("htrn_date", TransDate.ToString("yyyy-MM-dd HH:mm:ss"));
                ps.Set("cst_id", CstId);
                ps.Set("vouch_id", 1);
                ps.Set("voser_id", 1);
                ps.Set("htrn_docnum", HtrnDocnum);
                //ps.Set("user_id", UserId);
                //ps.Set("htrn_entry_date", HtrnEntryDate.ToString("yyyy-MM-dd HH:mm:ss"));
                ps.Set("htrn_expl", HtrnExpl);
                //ps.Set("htrn_net_val", HtrnNetVal);
                //ps.Set("htrn_vat_val", HtrnVatVal);

                if (IsNew)
                {
                    ps.Execute();

                    ps = conn.PrepareStatement(@"SELECT TOP 1 id FROM rtrans_hed ORDER BY id DESC");

                    IResultSet rs = ps.ExecuteQuery();
                    if (rs.Next())
                    {
                        HtrnId = rs.GetInt("id");
                    }
                }
                else
                {
                    ps.Execute();
                }

                ps.Close();

                if (TransDetList != null)
                {
                    foreach (var detail in TransDetList)
                    {
                        detail.Save(conn, this);
                    }
                }

                conn.Commit();
                conn.Release();
            }
        }
示例#6
0
        public void Save(IConnection conn, TransHed header)
        {
            CustomerInfo info = new CustomerInfo();

            IPreparedStatement ps;

            if (IsNew)
            {
                if (IsDeleted)
                {
                    return;
                }

                ps = conn.PrepareStatement(@"INSERT INTO rtrans_det
    (   
        htrn_id, dtrn_num, item_id, qty1, unit_price, disc_line1, net_value, vat_value
    )
VALUES
    (   
        :htrn_id
       ,:dtrn_num
       ,:item_id
       ,:dtrn_qty1
       ,:dtrn_unit_price
       ,:dtrn_disc_line1
       ,:dtrn_net_value
       ,:dtrn_vat_value )");

                ps.Set("htrn_id", header.HtrnId);
                ps.Set("dtrn_num", DtrnNum);
                ps.Set("item_id", ItemId);
                ps.Set("dtrn_qty1", DtrnQty1);
                ps.Set("dtrn_unit_price", DtrnUnitPrice);
                ps.Set("dtrn_disc_line1", DtrnDiscLine1);
                ps.Set("dtrn_net_value", DtrnNetValue);
                ps.Set("dtrn_vat_value", DtrnVatValue);

                ps.Execute();

                ps = conn.PrepareStatement(@"SELECT TOP 1 id FROM rtrans_det ORDER BY id DESC");

                IResultSet rs = ps.ExecuteQuery();
                if (rs.Next())
                {
                    DtrnId = rs.GetInt("id");
                }
            }
            else if (IsDeleted)
            {
                ps = conn.PrepareStatement(@"
DELETE FROM rtrans_det WHERE id = :dtrn_id ");
                ps.Set("dtrn_id", DtrnId);
                ps.Execute();
            }
            else
            {
                ps = conn.PrepareStatement(@"
UPDATE rtrans_det SET 
            htrn_id = :htrn_id
           ,dtrn_num = :dtrn_num
           ,item_id = :item_id
           ,qty1 = :dtrn_qty1
           ,unit_price = :dtrn_unit_price
           ,disc_line1 = :dtrn_disc_line1
           ,net_value = :dtrn_net_value
           ,vat_value = :dtrn_vat_value
WHERE id = :dtrn_id ");

                ps.Set("dtrn_id", DtrnId);
                ps.Set("htrn_id", header.HtrnId);
                ps.Set("dtrn_num", DtrnNum);
                ps.Set("item_id", ItemId);
                ps.Set("dtrn_qty1", DtrnQty1);
                ps.Set("dtrn_unit_price", DtrnUnitPrice);
                ps.Set("dtrn_disc_line1", DtrnDiscLine1);
                ps.Set("dtrn_net_value", DtrnNetValue);
                ps.Set("dtrn_vat_value", DtrnVatValue);

                ps.Execute();
            }

            ps.Close();
        }