示例#1
0
        public void addSupplierCbx()
        {
            bool flag = false;

            foreach (DataGridViewColumn dc in headerControl1.dgvSubcontract.Columns)
            {
                if (dc.Name == "colSupplier")
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                ls = SubContractorContract.getSuppliers();
                if (ls.Count > 0)
                {
                    DataTable dt = new DataTable();
                    dt = ObjectUtils.ConvertToDataTable(ls);

                    DataGridViewComboBoxColumn cb = new DataGridViewComboBoxColumn();
                    cb.HeaderText       = "Supplier";
                    cb.FlatStyle        = FlatStyle.Flat;
                    cb.Name             = "colSupplier";
                    cb.AutoSizeMode     = DataGridViewAutoSizeColumnMode.AllCells;
                    cb.DataSource       = dt;
                    cb.DataPropertyName = "SuplNoVal";
                    cb.ValueMember      = "strValue1";
                    cb.DisplayMember    = "strText";
                    cb.DisplayIndex     = 0;
                    cb.DisplayStyle     = DataGridViewComboBoxDisplayStyle.DropDownButton;
                    headerControl1.dgvSubcontract.Columns.Add(cb);
                }
            }
        }
示例#2
0
        private SubContractorContract rowToSubContractor(DataGridViewRow r)
        {
            SubContractorContract obj = new SubContractorContract();

            //obj.SuplNo = r.Cells[]

            return(obj);
        }
示例#3
0
        private List <SubContractorContract> replaceListSubContractorContract(List <SubContractorContract> list, SubContractorContract s)
        {
            //find index  by oid
            var idx = list.FindIndex(x => x.OID == s.OID);

            if (idx != null && idx >= 0)
            {
                list[idx] = s;
            }
            return(list);
        }
示例#4
0
        public SubContractorContract RowToSubcontractor(DataGridViewRow row)
        {
            SubContractorContract sc = new SubContractorContract();
            int  number = -1;
            bool tmp    = Int32.TryParse(row.Cells[0].Value.ToString(), out number);

            if (tmp)
            {
                sc.OID = number;
            }
            else
            {
                sc.OID = 0;
            }

            sc.SubcontractNo = row.Cells["colSubcontractNo"].Value != null ? row.Cells["colSubcontractNo"].Value.ToString() : "";
            sc.Info          = row.Cells["colInfo"].Value != null ? row.Cells["colInfo"].Value.ToString() : "";
            sc.Expl          = row.Cells["colExpl"].Value != null ? row.Cells["colExpl"].Value.ToString() : "";
            if ((DateTime)(row.Cells["colDateLimit"].Value) > DateTime.MinValue)
            {
                sc.DateLimit = MyUtils.strToDate(row.Cells["colDateLimit"].Value.ToString(), objGlobal.CultureInfo);
            }
            sc.KmLimit = row.Cells["colKmLimit"].Value != null ? (int)row.Cells["colKmLimit"].Value : 0;



            var  temp = (decimal)0;
            bool rs   = Decimal.TryParse(row.Cells["colBuyPrice"].Value.ToString(), out temp);

            if (rs)
            {
                sc.BuyPrice = Math.Round(temp, 2);
            }
            else
            {
                sc.BuyPrice = (decimal)0;
            }


            sc.SuplNoVal = row.Cells["colSuplNoVal"].Value != null ? row.Cells["colSuplNoVal"].Value.ToString() : "";
            sc.SuplName  = row.Cells["colSuplName"].Value != null ? row.Cells["colSuplName"].Value.ToString() : "";

            sc.isDeleted = (bool)row.Cells["colIsDeleted"].Value;

            clsBaseListItem t = new clsBaseListItem();

            t.strValue1 = sc.SuplNoVal;
            t.strText   = sc.SuplName;
            sc.SuplNo   = t;

            return(sc);
        }
示例#5
0
        private void btnNewSubcontractor_click(object sender, EventArgs e)
        {
            //MessageBox.Show("Test");
            SubContractorContract tmp = new SubContractorContract();

            subOid--;
            tmp.OID       = subOid;
            tmp.SuplNoVal = ls[0].strValue1;
            objContract.SubContracts.Add(tmp);
            var source = new BindingSource();

            source.DataSource = objContract.SubContracts;
            this.headerControl1.dgvSubcontract.DataSource = source;
            this.headerControl1.dgvSubcontract.Refresh();
        }
示例#6
0
        private void dgvSubcontract_CellValidated(object sender, DataGridViewCellEventArgs e)
        {
            //DataGridViewCellEventArgs me = (DataGridViewCellEventArgs)e;
            //if (me != null)

            DataGridViewRow r = this.headerControl1.dgvSubcontract.Rows[e.RowIndex];

            if (r != null)
            {
                SubContractorContract s = this.RowToSubcontractor(r);
                if (s != null)
                {
                    //longdq
                    objContract.SubContracts = this.replaceListSubContractorContract(objContract.SubContracts, s);
                }
            }
        }